<b>4.0.8.3331</b>
Alexey Kovyazin 2026.11.08 11:27:28
Mapping: do not hold populateMutex while attaching to a database
Mapping::ensureCachePresence() attached to the database under the cache
populateMutex. In a full shutdown a traced failed attach maps the user, its
nested attach is rejected, and when it is the last attachment it closes the
database: JRD_shutdown_database() waits for the garbage collector, while
the collector's last TRA_commit maps a user too and waits for the same
mutex (deadlock, IBSurgeon/hqbird#12).
Attach first and take the mutex only to check and populate the cache;
"cache = nullptr" runs after the mutex is released (the second bug in #12).
Change by Alex Peshkoff (12.patch in IBSurgeon/hqbird#12).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0b4a91efad17f9611fa13cc1cf30d91d119c4a52)

Changed paths:
  M src/jrd/Mapping.cpp