Skip to content

Commit bcb6462

Browse files
committed
Attempt to fix hanging transaction locks after various exceptions or BUGCHECK
1 parent 9b70579 commit bcb6462

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

src/jrd/jrd.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7667,6 +7667,17 @@ void release_attachment(thread_db* tdbb, Jrd::Attachment* attachment, XThreadEns
76677667

76687668
attachment->destroyIntlObjects(tdbb);
76697669

7670+
{
7671+
// Destroy transactions and release their locks
7672+
// before detaching them from the attachment.
7673+
jrd_tra* next = NULL;
7674+
for (jrd_tra* tran = attachment->att_transactions; tran; tran = next)
7675+
{
7676+
next = tran->tra_next;
7677+
jrd_tra::destroy(attachment, tran);
7678+
}
7679+
}
7680+
76707681
attachment->detachLocks();
76717682

76727683
LCK_fini(tdbb, LCK_OWNER_attachment);
@@ -7758,15 +7769,6 @@ void release_attachment(thread_db* tdbb, Jrd::Attachment* attachment, XThreadEns
77587769

77597770
delete attachment->att_user;
77607771

7761-
{
7762-
jrd_tra* next = NULL;
7763-
for (jrd_tra* tran = attachment->att_transactions; tran; tran = next)
7764-
{
7765-
next = tran->tra_next;
7766-
jrd_tra::destroy(attachment, tran);
7767-
}
7768-
}
7769-
77707772
tdbb->setAttachment(NULL);
77717773
Jrd::Attachment::destroy(attachment);
77727774
}

src/jrd/lck.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,18 +1483,19 @@ Lock::Lock(thread_db* tdbb, USHORT length, lck_t type, void* object, lock_ast_t
14831483

14841484
Lock::~Lock()
14851485
{
1486-
fb_assert(lck_id == 0);
1487-
fb_assert(!lck_attachment.hasData());
1488-
1489-
if (lck_attachment || lck_next || lck_prior)
1486+
// lck_id might be set if exception or bugcheck occurs
1487+
if (lck_id)
14901488
{
14911489
#ifdef DEBUG_LCK_LIST
1492-
gds__log("DEBUG_LCK_LIST: Lock::~Lock(): this 0x%p, attachment 0x%p, lck_type %d, lck_next 0x%p, lck_prior 0x%p",
1493-
this, lck_attachment ? lck_attachment->getHandle() : NULL,
1494-
(int) lck_type, lck_next, lck_prior);
1490+
if (lck_attachment || lck_next || lck_prior)
1491+
{
1492+
gds__log("DEBUG_LCK_LIST: Lock::~Lock(): this 0x%p, attachment 0x%p, lck_type %d, lck_next 0x%p, lck_prior 0x%p",
1493+
this, lck_attachment ? lck_attachment->getHandle() : NULL,
1494+
(int) lck_type, lck_next, lck_prior);
1495+
}
14951496
#endif
14961497

1497-
setLockAttachment(NULL);
1498+
LCK_release(JRD_get_thread_data(), this);
14981499
}
14991500
}
15001501

src/jrd/tra.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3790,6 +3790,7 @@ jrd_tra::~jrd_tra()
37903790
MemoryPool::deletePool(tra_autonomous_pool);
37913791

37923792
delete tra_sec_db_context;
3793+
delete tra_lock;
37933794
}
37943795

37953796

0 commit comments

Comments
 (0)