It's better when it's simple

User Tools

Site Tools


Translations of this page?:

Learn about DokuWiki

Advanced Use

Corporate Use

Our Community

Follow us on Facebook, Twitter and other social networks.

Our Privacy Policy


This is an old revision of the document!

Page locking

The page locking mechanism is based around a .lock file that temporarily exists within the dokuwiki/data/locks directory.

When a page is edited, a .lock file is created by the lock() function. The name of this file is determined through the ID of the page that is requested to be locked, hashed by MD5. This file is written with, as content, the USER_NAME or the client IP.

The release of a lock is done by deleting the .lock file. This is achieved by the unlock() function.

Checking for an existing lock is handled by the checklock() function. This function will also take care of removing stale lock files.

Due to current limitations of the design, the lock(), unlock() and checklock() lack proper lock atomicity. lock() performs lock stealing: it replaces the lock of another process unconditionally.

The typical program flow:

if (!checklock($id)) {
    // work
} else {
    // error

avoids lock stealing in the typical case, where the attempts to lock a page are few and far between. However, in a scenario of two concurrent processes, where the checklock() function is called in the first process, then it is called again in the second process leaves both processes assuming that they are free to lock the page. One of them will inadvertently steal the lock from the other.

devel/locking.1344184956.txt.gz · Last modified: 2012-08-05 18:42 by