Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/jrd/extds/ExtDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,15 +1639,30 @@ void Transaction::rollback(thread_db* tdbb, bool retain)
doRollback(&status, tdbb, retain);

Connection& conn = m_connection;
if (!retain)
const bool hasErrors = status->getState() & IStatus::STATE_ERRORS;

const auto cleanup = [&]()
{
detachFromJrdTran();
m_connection.deleteTransaction(tdbb, this);
}
if (!retain)
{
detachFromJrdTran();
m_connection.deleteTransaction(tdbb, this);
}
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use class Cleanup here and avoid re-throw and explicit cleanup ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered below #8991 (comment)


if (status->getState() & IStatus::STATE_ERRORS) {
conn.raise(&status, tdbb, "transaction rollback");
try
{
if (hasErrors) {
conn.raise(&status, tdbb, "transaction rollback");
}
}
catch (const Exception&)
{
cleanup();
throw;
}

cleanup();
}

Transaction* Transaction::getTransaction(thread_db* tdbb, Connection* conn, TraScope tra_scope)
Expand Down
Loading