Skip to content

Commit 3b2489c

Browse files
committed
Fixed bug #8386 : Crash when creating index on table that uses UDR and ParallelWorkers > 1
1 parent 2d6bb14 commit 3b2489c

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/jrd/WorkerAttachment.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ WorkerStableAttachment::~WorkerStableAttachment()
7676
fini();
7777
}
7878

79-
WorkerStableAttachment* WorkerStableAttachment::create(FbStatusVector* status, Jrd::Database* dbb)
79+
WorkerStableAttachment* WorkerStableAttachment::create(FbStatusVector* status, Database* dbb, JProvider* provider)
8080
{
8181
Attachment* attachment = NULL;
8282
try
8383
{
84-
attachment = Attachment::create(dbb, NULL);
84+
attachment = Attachment::create(dbb, provider);
8585
attachment->att_filename = dbb->dbb_filename;
8686
attachment->att_flags |= ATT_worker;
8787

@@ -120,6 +120,8 @@ void WorkerStableAttachment::fini()
120120
BackgroundContextHolder tdbb(dbb, attachment, &status_vector, FB_FUNCTION);
121121

122122
Monitoring::cleanupAttachment(tdbb);
123+
dbb->dbb_extManager->closeAttachment(tdbb, attachment);
124+
123125
attachment->releaseLocks(tdbb);
124126
LCK_fini(tdbb, LCK_OWNER_attachment);
125127

@@ -433,18 +435,17 @@ StableAttachmentPart* WorkerAttachment::doAttach(FbStatusVector* status, Databas
433435
{
434436
StableAttachmentPart* sAtt = NULL;
435437

438+
AutoPlugin<JProvider> jInstance(JProvider::getInstance());
439+
//jInstance->setDbCryptCallback(&status, tdbb->getAttachment()->att_crypt_callback);
440+
436441
if (Config::getServerMode() == MODE_SUPER)
437-
sAtt = WorkerStableAttachment::create(status, dbb);
442+
sAtt = WorkerStableAttachment::create(status, dbb, jInstance);
438443
else
439444
{
440445
ClumpletWriter dpb(ClumpletReader::Tagged, MAX_DPB_SIZE, isc_dpb_version1);
441446
dpb.insertString(isc_dpb_trusted_auth, DBA_USER_NAME);
442447
dpb.insertInt(isc_dpb_worker_attach, 1);
443448

444-
AutoPlugin<JProvider> jInstance(JProvider::getInstance());
445-
446-
//jInstance->setDbCryptCallback(&status, tdbb->getAttachment()->att_crypt_callback);
447-
448449
JAttachment* jAtt = jInstance->attachDatabase(status, dbb->dbb_filename.c_str(),
449450
dpb.getBufferLength(), dpb.getBuffer());
450451

@@ -456,6 +457,7 @@ StableAttachmentPart* WorkerAttachment::doAttach(FbStatusVector* status, Databas
456457
{
457458
sAtt->addRef(); // !!
458459
sAtt->getHandle()->setIdleTimeout(WORKER_IDLE_TIMEOUT);
460+
jInstance->addRef();
459461
}
460462

461463
return sAtt;
@@ -465,6 +467,15 @@ void WorkerAttachment::doDetach(FbStatusVector* status, StableAttachmentPart* sA
465467
{
466468
status->init();
467469

470+
AutoPlugin<JProvider> provider;
471+
{
472+
AttSyncLockGuard guard(*sAtt->getSync(), FB_FUNCTION);
473+
474+
Attachment* attachment = sAtt->getHandle();
475+
if (attachment)
476+
provider.reset(attachment->getProvider());
477+
}
478+
468479
// if (att->att_flags & ATT_system)
469480
if (Config::getServerMode() == MODE_SUPER)
470481
{

src/jrd/WorkerAttachment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace Jrd
4646
class WorkerStableAttachment : public SysStableAttachment
4747
{
4848
public:
49-
static WorkerStableAttachment* create(FbStatusVector* status, Jrd::Database* dbb);
49+
static WorkerStableAttachment* create(FbStatusVector* status, Database* dbb, JProvider* provider);
5050

5151
void fini();
5252

0 commit comments

Comments
 (0)