Time out error while waiting to lock object - sql

My procedure fails at times, and further investigation reveals that it is always the same error:
ORA-12801: error signaled in parallel query server P02U
ORA-04021: timeout occurred while waiting to lock object
ORA-06512: at "USP_ALGO_REPORT", line 645
I've tried several things (don't know if they are helpful or not), for instance, bringing down from parallel(16) to parallel(8) for all my select statements inside the procedure, changing the timings when the procedure is scheduled to run etc.
Please let me know If I can provide further information that can help understand the problem.
Thank you.

My procedure fails at times
Check error ORA-06512 in Docs.
Fix the problem causing the exception or write an exception handler for this condition on line 645.
Like:
if something
return 1

after performing DML statements, try to commit.
timeout occurred while waiting to lock object
at cases,this resolves the timeout issue.
committing the session releases the locking object can can be used for next command....

Related

SqlException Timeout expired

Why below error comes?
System.Data.SqlClient.SqlException Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding
You should normally try to write fast sql (<100ms) otherwise your application will be sluggish for the end users.
If your server reply in time when you send the request manually,
There may be a read lock on a table and the second query keep on waiting for the read lock to end before processing.
In that case try to add WITH(NOLOCK) or WITH(READUNCOMMITTED) to your select statement.
Acccording to your situation and err msg, I think it may be caused by mainly two reasons:
Long running tasks:In default SQL Connection will wait for 30 seconds, but over this time, if you still cannot connect to the db, the kind of error will be thrown out.
For the second reason, that there might be an uncommitted transaction.
Of course, you should Close Connnection at a time when you don't want to use it (using…… statement is recommanded)
See more about this kind of issue, you can refer to:
http://blogs.msdn.com/b/spike/archive/2008/07/31/timeout-expired-the-timeout-period-elapsed-prior-to-completion-of-the-operation-or-the-server-is-not-responding.aspx

What causes the "procedure has not been executed or has no result" error and how to prevent it?

Recently we are getting the "procedure has not been executed or has no result" across our PowerBuilder Application. This error is random, but is triggered in places where we have calls to Stored Procedures or some dynamic SQL queries. After each call to the procedure, we close the procedure in powerbuilder. We need to know the cause of this error because this is not caused on our environment, only in the production environment. Even better would be a way to resolve this issue.
The database is SQL Server. The exact error details are as follows:
ERROR Code: -1
ERROR Text: procedure has not been executed or has no result
Row Count: 0
Terminating application-
I am not even sure if the error is from Database or from Powerbuilder itself. The code is a simple call to a procedure. Here is some code that is causing this issue:
DECLARE setRequestStatus PROCEDURE FOR sRequestStatus
// parameters here
USING SQLCA;
EXECUTE setRequestStatus;
FETCH setRequestStatus into :statusCode;
CLOSE sp_PfW_ERxSetRequestStatus;
RETURN statusCode
Do reply if you need any more details.
Thanks in advance!
According to this post, the problem is an exception being raised by your stored procedure-- possibly due to transaction size. Follow the link to get more details.

ORA-02048 - Attempt to begin distributed transaction without loggin on

anyone know something about this error?
ORA-02048: attempt to begin distributed transaction without logging on
ORA-02063: preceding line from ..dblink
It occurs when I invoke since Java a PL/SQL Package that contains dblinks to access to other database for insert data. The dblink works good with other clauses, but not in this Package.
If I invoke this PL/SQL Package since TOAD, it works good.
I'm trying to reproduce this error, and I see this error arises from a pattern:
When I click the button which makes the PL run, the log shows me an error "ora-02292 integrity constraint child record found", and the next time I click the button, appears the error "ORA-02048", it is like the first error did lose the connection with remote database.
Thanks in advance
Without seeing a minimal testcase that demonstrates the problem, it's impossible to say.
However, looking up the error message:
-bash-4.1$ oerr ora 2048
02048, 00000, "attempt to begin distributed transaction without logging on"
// *Cause: client program must issue a distributed transaction login.
// *Action: contact support.
So, I'd recommend contacting Oracle support and opening an SR. But, the first thing they're likely to ask for is a working test case that demonstrates the problem.
The problem was thatI have different procedures, like that:
procedure1 -> (call) -> procedure 2 -> (call) -> procedure3
In procedure3 I have a clausure with dblink that insert into a remote table.
Procedure1 catchs the exceptions that may occur in procedure 2 and procedure3.
The problem is when an exception is throw in procedure3. In this case the rollback placed in the exception catch of procedure1, should finish the transaction, but it isn't working as I expected. The transaction is this case remains open and the second time in the procedure executions, oracle shows me the ORA-02048 error.
The solution was moving the exception catch into procedure3.

How can I force a Snapshot Isolation failure of 3960

Story
I have a SPROC using Snapshot Isolation to perform several inserts via MERGE. This SPROC is called with very high load and often in parallel so it occasionally throws an Error 3960- which indicates the snapshot rolled back because of change conflicts. This is expected because of the high concurrency.
Problem
I've implemented a "retry" queue to perform this work again later on, but I am having difficulty reproducing the error to verify my checks are accurate.
Question
How can I reproduce a snapshot failure (3960, specifically) to verify my retry logic is working?
Already Tried
RAISEERROR doesn't work because it doesn't allow me to raise existing errors, only user defined ones
I've tried re-inserted the same record, but this doesn't throw the same failure since it's not two different transactions "racing" another
Open two connections, start a snapshot transaction on both, on connection 1 update a record, on the connection 2 update the same record (in background because it will block), then on connection 1 commit
Or treat a user error as a 3960 ...
Why not just do this:
RAISERROR(3960, {sev}, {state})
Replacing {sev} and {state} with the actual values that you see when the error occurs in production?
(Nope, as Martin pointed out, that doesn't work.)
If not that then I would suggest trying to run your test query multiple times simultaneously. I have done this myself to simulate other concurrency errors. It should be doable as long as the test query is not too fast (a couple of seconds at least).

Should I finalize my statements if the SQLite database is reported to be corrupt SQLITE_CORRUPT

I recieve SQLITE_CORRUPT error for the database being corrupt.
wrong # of entries in index sqlite_autoindex_Settings_1
In my code I have a try/finally clause in which I always try to always sqlite3_finalize my statements.
Apparently on a corrupted database trying to finalize the statement raises again SQLITE_CORRUPT.
Question: Should I finalize my statements if the database is reported to be corrupted?
before sqlite3_finalize or after every sqlite3_step use sqlite3_reset.
The sqlite3_reset(S) interface resets the prepared statement S back to the beginning of its program.
check whether you have sqlite3_reset after every sqlite3_step because this is one case that causes database to be corrupt. after preparing a statement with sqlite3_prepare and executing it with sqlite3_step,you need to always reset it with sqlite3_reset.
The sqlite3_reset(S) interface resets the prepared statement S back
to the beginning of its program.
before sqlite3_finalize or after every sqlite3_step use sqlite3_reset.
hope this solves your problem...!!!