Skip to content

Commit 4ddbb69

Browse files
committed
Fixed bug #8386 : Crash when creating index on table that uses UDR and ParallelWorkers > 1
1 parent 9d7f7a2 commit 4ddbb69

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/jrd/WorkerAttachment.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ const unsigned WORKER_IDLE_TIMEOUT = 60; // 1 minute
5050
/// class WorkerStableAttachment
5151

5252
WorkerStableAttachment::WorkerStableAttachment(FbStatusVector* status, Jrd::Attachment* attachment) :
53-
SysStableAttachment(attachment)
53+
SysStableAttachment(attachment),
54+
m_provider(attachment->getProvider())
5455
{
5556
UserId user;
5657
user.setUserName("<Worker>");
@@ -69,19 +70,20 @@ WorkerStableAttachment::WorkerStableAttachment(FbStatusVector* status, Jrd::Atta
6970
Monitoring::publishAttachment(tdbb);
7071

7172
initDone();
73+
m_provider->addRef();
7274
}
7375

7476
WorkerStableAttachment::~WorkerStableAttachment()
7577
{
7678
fini();
7779
}
7880

79-
WorkerStableAttachment* WorkerStableAttachment::create(FbStatusVector* status, Jrd::Database* dbb)
81+
WorkerStableAttachment* WorkerStableAttachment::create(FbStatusVector* status, Database* dbb, JProvider* provider)
8082
{
8183
Attachment* attachment = NULL;
8284
try
8385
{
84-
attachment = Attachment::create(dbb, NULL);
86+
attachment = Attachment::create(dbb, provider);
8587
attachment->att_filename = dbb->dbb_filename;
8688
attachment->att_flags |= ATT_worker;
8789

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

122124
Monitoring::cleanupAttachment(tdbb);
125+
dbb->dbb_extManager->closeAttachment(tdbb, attachment);
126+
123127
attachment->releaseLocks(tdbb);
124128
LCK_fini(tdbb, LCK_OWNER_attachment);
125129

@@ -433,18 +437,17 @@ StableAttachmentPart* WorkerAttachment::doAttach(FbStatusVector* status, Databas
433437
{
434438
StableAttachmentPart* sAtt = NULL;
435439

440+
AutoPlugin<JProvider> jInstance(JProvider::getInstance());
441+
//jInstance->setDbCryptCallback(&status, tdbb->getAttachment()->att_crypt_callback);
442+
436443
if (Config::getServerMode() == MODE_SUPER)
437-
sAtt = WorkerStableAttachment::create(status, dbb);
444+
sAtt = WorkerStableAttachment::create(status, dbb, jInstance);
438445
else
439446
{
440447
ClumpletWriter dpb(ClumpletReader::Tagged, MAX_DPB_SIZE, isc_dpb_version1);
441448
dpb.insertString(isc_dpb_trusted_auth, DBA_USER_NAME);
442449
dpb.insertInt(isc_dpb_worker_attach, 1);
443450

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

src/jrd/WorkerAttachment.h

Lines changed: 3 additions & 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

@@ -56,6 +56,8 @@ class WorkerStableAttachment : public SysStableAttachment
5656
private:
5757
explicit WorkerStableAttachment(FbStatusVector* status, Jrd::Attachment* att);
5858
virtual ~WorkerStableAttachment();
59+
60+
Firebird::AutoPlugin<JProvider> m_provider;
5961
};
6062

6163

0 commit comments

Comments
 (0)