Skip to content

Commit

Permalink
Fixed bug #8386 : Crash when creating index on table that uses UDR an…
Browse files Browse the repository at this point in the history
…d ParallelWorkers > 1
  • Loading branch information
hvlad committed Jan 15, 2025
1 parent 9d7f7a2 commit 4ddbb69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 11 additions & 8 deletions src/jrd/WorkerAttachment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const unsigned WORKER_IDLE_TIMEOUT = 60; // 1 minute
/// class WorkerStableAttachment

WorkerStableAttachment::WorkerStableAttachment(FbStatusVector* status, Jrd::Attachment* attachment) :
SysStableAttachment(attachment)
SysStableAttachment(attachment),
m_provider(attachment->getProvider())
{
UserId user;
user.setUserName("<Worker>");
Expand All @@ -69,19 +70,20 @@ WorkerStableAttachment::WorkerStableAttachment(FbStatusVector* status, Jrd::Atta
Monitoring::publishAttachment(tdbb);

initDone();
m_provider->addRef();
}

WorkerStableAttachment::~WorkerStableAttachment()
{
fini();
}

WorkerStableAttachment* WorkerStableAttachment::create(FbStatusVector* status, Jrd::Database* dbb)
WorkerStableAttachment* WorkerStableAttachment::create(FbStatusVector* status, Database* dbb, JProvider* provider)
{
Attachment* attachment = NULL;
try
{
attachment = Attachment::create(dbb, NULL);
attachment = Attachment::create(dbb, provider);
attachment->att_filename = dbb->dbb_filename;
attachment->att_flags |= ATT_worker;

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

Monitoring::cleanupAttachment(tdbb);
dbb->dbb_extManager->closeAttachment(tdbb, attachment);

attachment->releaseLocks(tdbb);
LCK_fini(tdbb, LCK_OWNER_attachment);

Expand Down Expand Up @@ -433,18 +437,17 @@ StableAttachmentPart* WorkerAttachment::doAttach(FbStatusVector* status, Databas
{
StableAttachmentPart* sAtt = NULL;

AutoPlugin<JProvider> jInstance(JProvider::getInstance());
//jInstance->setDbCryptCallback(&status, tdbb->getAttachment()->att_crypt_callback);

if (Config::getServerMode() == MODE_SUPER)
sAtt = WorkerStableAttachment::create(status, dbb);
sAtt = WorkerStableAttachment::create(status, dbb, jInstance);
else
{
ClumpletWriter dpb(ClumpletReader::Tagged, MAX_DPB_SIZE, isc_dpb_version1);
dpb.insertString(isc_dpb_trusted_auth, DBA_USER_NAME);
dpb.insertInt(isc_dpb_worker_attach, 1);

AutoPlugin<JProvider> jInstance(JProvider::getInstance());

//jInstance->setDbCryptCallback(&status, tdbb->getAttachment()->att_crypt_callback);

JAttachment* jAtt = jInstance->attachDatabase(status, dbb->dbb_filename.c_str(),
dpb.getBufferLength(), dpb.getBuffer());

Expand Down
4 changes: 3 additions & 1 deletion src/jrd/WorkerAttachment.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace Jrd
class WorkerStableAttachment : public SysStableAttachment
{
public:
static WorkerStableAttachment* create(FbStatusVector* status, Jrd::Database* dbb);
static WorkerStableAttachment* create(FbStatusVector* status, Database* dbb, JProvider* provider);

void fini();

Expand All @@ -56,6 +56,8 @@ class WorkerStableAttachment : public SysStableAttachment
private:
explicit WorkerStableAttachment(FbStatusVector* status, Jrd::Attachment* att);
virtual ~WorkerStableAttachment();

Firebird::AutoPlugin<JProvider> m_provider;
};


Expand Down

0 comments on commit 4ddbb69

Please sign in to comment.