top of page


The library cache, which is part of the shared pool in the Oracle instance, contains the definition of different objects, cursors, indexes, tables, functions, packages. When these objects are in use, they cannot be changed.

If someone is updating a table, you cannot change the definition of the table. If someone is using a procedure, you cannot compile the procedure. If someone is using an index, you cannot drop the index.


The ORA-04021 timeout error is most likely caused by another session locking/using a package that you are attempting to execute.

Why can’t you alter these objects, while in use?

These objects are locked in the library cache, by a mechanism based on library locks and library pins.

When a user wants to use an object, the session must obtain a library cache lock in null, shared, or exclusive mode on the objects, depending on the operation.

If you want to drop a table, you need an exclusive lock. This lock will prevent other sessions from executing the same operation, or other disruptive operations (dropping the object).

After the lock is acquired on the object, the session also must obtain a pin in a specific mode: null, shared, exclusive, depending on the operation.

A session that is waiting on an object already locked/pinned in the library cache, that is incompatible with the requested mode, will wait on events similar to library cache pin or library cache lock, for a limited time, at which point a timeout occurs.

Usually the timeout occurs after 5 minutes, and the waiting user will receive the ORA-4021 message TIMEOUT OCCURRED WHILE WAITING TO LOCK OBJECT.

You most likely want to troubleshoot and see who is holding a lock on your object. The problem is that the troubleshooting has to happen during the wait period, before the ORA-4021 occurs. I recommend that you start investigating when you see that your session is waiting, or hanging, and the session cursor is not returned to you right away.

Views that you can use to troubleshoot:


You can start your troubleshooting by checking regular blocking/locking issues.


Contact the Oracle team to analyze your situation. As general workaround you can stop and start the business events listeners, clearing cache from Oracle side. Then removed the locks on the tables. You'll need Oracle DBA help.

For more information visit:

9,155 views0 comments

Recent Posts

See All

How to Connect MySQL Without Root Password.

Many times, I got the question from my colleague or training participants, how to login MySQL if I forgot the password. I have explained the process in many times to them but thought to write this sce

Step by Step Oracle 21c Installation on Linux

Oracle Database 21c is the first Oracle database release with CDB-only architecture. Oracle 20c was announced only CDB architecture but it was not release for on premises. Only for Cloud. That's why i


bottom of page