Clearing Stale Locks

Stephen Marquard

We have a site on our test Sakai 2.0.0 server which seems to have a stale lock.

If you try to edit it (logged in as admin), you get the message "Alert: Someone else is currently editing this Site: uct-demo".

Glenn Golden

Restarting Sakai and rebooting the server don't help, so I'm assuming there's a stale lock set in the database which isn't being cleared. Is there an easy way of fixing this?

Check your locks table. In unusual circumstances, locks can get stuck on. You can clear them manually from the database directly:

Here's some Oracle script to check the locks and clear any from closed sessions. You can use this, or just manually delete the lock record you will recognize that is out of place:

All Locks
select
TABLE_NAME, RECORD_ID, to_char(LOCK_TIME,'YYYY-MM-DD  HH24:MI:SS'), USAGE_SESSION_ID, SESSION_USER, SESSION_SERVER
from SAKAI_LOCKS, SAKAI_SESSION
where USAGE_SESSION_ID = SESSION_ID
order by LOCK_TIME ASC;
Locks from Closed Sessions
select SL.TABLE_NAME, SL.RECORD_ID,
to_char(SL.LOCK_TIME,'YYYY-MM-DD HH24:MI:SS') as LOCK_TIME,
SL.USAGE_SESSION_ID,
CS.SESSION_USER,
CS.SESSION_SERVER,
to_char(CS.SESSION_END, 'YYYY-MM-DD HH24:MI:DD') as SESSION_END
from SAKAI_LOCKS SL, SAKAI_SESSION CS
where SL.USAGE_SESSION_ID = CS.SESSION_ID
and SL.USAGE_SESSION_ID NOT IN
(select session_id from sakai_session where SESSION_START =  SESSION_END)
order by SL.LOCK_TIME ASC;
Clear Locks from Closed Sessions
delete from sakai_locks where usage_session_id NOT IN (select 
SL.USAGE_SESSION_ID from SAKAI_LOCKS SL, SAKAI_SESSION CS where  
SL.USAGE_SESSION_ID = CS.SESSION_ID and CS.SESSION_START =  CS.SESSION_END);

Jon Andersen: 7/1/2005 on sakai-dav

There was a question earlier about clearing edit locks. The question was raised, can the locks be cleared without cycling the server.

Background - Sakai uses pessimistic locking - every time an edit is occurring, there is a lock on the object until the edit completes. Sometimes the lock isn't released, for various reasons (someone leaves an edit browser window open and walks away, etc).

There is a way for a Sakai administrator to clear all locks; however, its a little risky in a large production system (thousands of users) as it also clears all cached data, and so there may be a bit of sluggishness right after the locks are cleared.

To clear all locks:

  1. Login as a Sakai administrator
  2. Click the "Memory" page (on the left hand side)
  3. Click "Reset all caches".
    Done.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Oct 07, 2005

    Omer Piperdi says:

    Just wondering in second query... no chefsession table comes with SAKAI 2.0.0..

    Just wondering in second query... no chef_session table comes with SAKAI 2.0.0..