Skip to content

Fix self-deadlock when acquiring a shared SyncObject latch - #9120

Open
MochalovAlexey wants to merge 1 commit into
FirebirdSQL:v5.0-releasefrom
MochalovAlexey:syncobject_deadlock
Open

Fix self-deadlock when acquiring a shared SyncObject latch#9120
MochalovAlexey wants to merge 1 commit into
FirebirdSQL:v5.0-releasefrom
MochalovAlexey:syncobject_deadlock

Conversation

@MochalovAlexey

Copy link
Copy Markdown
Contributor

This fixes a possible engine hang when the current thread tries to acquire
a SYNC_SHARED latch on a SyncObject that it already owns exclusively.

The hang was observed several times in a customer environment, but so far
it has not been possible to reproduce it manually with an unmodified build.
The problematic lock sequence was reproduced only by temporarily modifying
the code and running it in a debugger.

Instead of waiting on itself, SyncObject now detects this condition and
raises a dedicated error. Page-cache latches are unwound when the exception
propagates through VIO record operations, backout and savepoint cleanup.

The fix was originally implemented for the 3v and has been adapted
to the Firebird 5.

Detect attempts to acquire SYNC_SHARED when the current thread already
owns SYNC_EXCLUSIVE and unwind page-cache latches when propagating the
resulting exception from VIO operations.
@hvlad

hvlad commented Aug 7, 2026

Copy link
Copy Markdown
Member

The hang was observed several times in a customer environment

No memory dump or stack trace ? What Firebird version is affected ?

Instead of waiting on itself, SyncObject now detects this condition and
raises a dedicated error. Page-cache latches are unwound when the exception
propagates through VIO record operations, backout and savepoint cleanup.

What about other usages of SyncObject ? Other usages of bdb_sync ?

Excuse me, but it looks like desperate attempt to workaround bug instead of properly fix it.
Also, I see no guarantee that it covers all possible cases - as there is no knowledge when and how it happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants