mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-02-02 10:00:38 +01:00
Restore correct order of trace events when attempt to attach failed.
Ensure there is no double ATTACH or DETACH events for the same connection. It also should fix FBT test bugs.core_4337.
This commit is contained in:
parent
391e635495
commit
97447ecc01
@ -8631,27 +8631,23 @@ static void getUserInfo(UserId& user, const DatabaseOptions& options, const char
|
||||
static void unwindAttach(thread_db* tdbb, const char* filename, const Exception& ex,
|
||||
FbStatusVector* userStatus, unsigned flags, const DatabaseOptions& options, Mapping& mapping, ICryptKeyCallback* callback)
|
||||
{
|
||||
bool attTraced = false;
|
||||
try
|
||||
{
|
||||
auto att = tdbb->getAttachment();
|
||||
if (att && att->att_trace_manager && att->att_trace_manager->isActive())
|
||||
const auto att = tdbb->getAttachment();
|
||||
TraceManager* traceManager = att ? att->att_trace_manager : nullptr;
|
||||
if (att && traceManager && traceManager->isActive())
|
||||
{
|
||||
TraceManager* traceManager = att->att_trace_manager;
|
||||
TraceConnectionImpl conn(att);
|
||||
TraceStatusVectorImpl traceStatus(userStatus, TraceStatusVectorImpl::TS_ERRORS);
|
||||
|
||||
if (traceManager->needs(ITraceFactory::TRACE_EVENT_ATTACH))
|
||||
traceManager->event_attach(&conn, flags & UNWIND_CREATE, ITracePlugin::RESULT_FAILED);
|
||||
|
||||
if (traceManager->needs(ITraceFactory::TRACE_EVENT_ERROR))
|
||||
{
|
||||
const char* func = flags & UNWIND_CREATE ? "JProvider::createDatabase" : "JProvider::attachDatabase";
|
||||
traceManager->event_error(&conn, &traceStatus, func);
|
||||
}
|
||||
|
||||
attTraced = true;
|
||||
}
|
||||
else
|
||||
trace_failed_attach(filename, options, flags & UNWIND_CREATE, userStatus, callback);
|
||||
|
||||
const char* func = flags & UNWIND_CREATE ? "JProvider::createDatabase" : "JProvider::attachDatabase";
|
||||
transliterateException(tdbb, ex, userStatus, func);
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
@ -8686,28 +8682,30 @@ static void unwindAttach(thread_db* tdbb, const char* filename, const Exception&
|
||||
sAtt->manualLock(flags);
|
||||
if (sAtt->getHandle())
|
||||
{
|
||||
TraceManager* traceManager = attachment->att_trace_manager;
|
||||
TraceConnectionImpl conn(attachment);
|
||||
|
||||
if (traceManager->needs(ITraceFactory::TRACE_EVENT_DETACH))
|
||||
traceManager->event_detach(&conn, false);
|
||||
|
||||
attachment->att_flags |= flags;
|
||||
release_attachment(tdbb, attachment);
|
||||
}
|
||||
else
|
||||
{
|
||||
tdbb->setAttachment(nullptr);
|
||||
sAtt->manualUnlock(flags);
|
||||
}
|
||||
}
|
||||
|
||||
JRD_shutdown_database(dbb, SHUT_DBB_RELEASE_POOLS |
|
||||
(flags & UNWIND_INTERNAL ? SHUT_DBB_OVERWRITE_CHECK : 0));
|
||||
|
||||
if (!attTraced)
|
||||
trace_failed_attach(filename, options, flags & UNWIND_CREATE, userStatus, callback);
|
||||
}
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
transliterateException(tdbb, ex, userStatus, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -464,11 +464,15 @@ void TraceManager::event_attach(ITraceDatabaseConnection* connection,
|
||||
{
|
||||
EXECUTE_HOOKS(trace_attach,
|
||||
(connection, create_db, att_result));
|
||||
|
||||
trace_needs &= ~(FB_CONST64(1) << ITraceFactory::TRACE_EVENT_ATTACH);
|
||||
}
|
||||
|
||||
void TraceManager::event_detach(ITraceDatabaseConnection* connection, bool drop_db)
|
||||
{
|
||||
EXECUTE_HOOKS(trace_detach, (connection, drop_db));
|
||||
|
||||
trace_needs &= ~(FB_CONST64(1) << ITraceFactory::TRACE_EVENT_DETACH);
|
||||
}
|
||||
|
||||
void TraceManager::event_transaction_start(ITraceDatabaseConnection* connection,
|
||||
|
Loading…
Reference in New Issue
Block a user