There is 1 comment.
 
 
XWiki Platform / cid:jira-generated-image-avatar-bb3c0be6-4f90-4a10-83c5-d5f3468b5c05 XWIKI-25019 Open

Acquiring a document lock can fail with a deadlock on MySQL

 
View issue   ยท   Add comment
 

1 comment

 
cid:jira-generated-image-avatar-7a9fc607-239e-4723-a1ce-09f2fcb2d3a0 Marius Dumitru Florea on 18/Sep/26 14:07
 

Verification

Ran ConfigurableClassIT#testLockingAndUnlocking 20 times against MySQL + Tomcat + Chrome, locally:

Configuration Repetitions Assertion failures Deadlocks (SQL Error: 1213)
Current master (READ COMMITTED, after XWIKI-24997) 20 0 1, on lock/XWiki/XWikiPreferences
hibernate.connection.isolation pinned to REPEATABLE READ (the behaviour before XWIKI-24997) 20 0 0
With the fix, REPEATABLE READ 20 0 0

Two things this shows:

  • XWIKI-24997 narrows the window a lot โ€” it removes the gap locks that a DELETE matching no row takes under REPEATABLE READ โ€” but it does not close it: a lock request still deadlocked at READ COMMITTED. That one happened to hit XWiki.XWikiPreferences, which this test does not assert on; had it hit the configurable page the test would have failed. Under READ COMMITTED InnoDB still uses gap locks for duplicate-key checking on insert, and saveLock runs concurrently for the same document id.
  • This machine never reproduces the assertion failure itself, in either isolation level, so the local runs show the absence of a regression rather than a before/after on the test. The failure rate that matters is the one on ci.xwiki.org, where the MySQL environment failed in 4 of the 6 master builds sampled between 2026-08-29 and 2026-09-16.

The fix therefore retries the write when the database refuses the locks it needs, rather than relying on the isolation level to make the deadlock impossible.

Also ran the default HSQLDB configuration with Firefox, 20 repetitions, green โ€” no regression outside MySQL.