MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / rollbackTransaction

Method rollbackTransaction

src/Interpreters/TransactionLog.cpp:537–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

535}
536
537void TransactionLog::rollbackTransaction(const MergeTreeTransactionPtr & txn) noexcept
538{
539 LockMemoryExceptionInThread memory_tracker_lock(VariableContext::Global);
540 LOG_TRACE(log, "Rolling back transaction {}{}", txn->tid,
541 std::uncaught_exceptions() ? fmt::format(" due to uncaught exception (code: {})", getCurrentExceptionCode()) : "");
542
543 if (!txn->rollback())
544 {
545 /// Transaction was cancelled or committed concurrently
546 chassert(txn->csn != Tx::UnknownCSN);
547 return;
548 }
549
550 {
551 auto requests = txn->getRequestsOnRollback();
552 if (!requests.empty())
553 {
554 Coordination::Responses responses;
555 auto code = getZooKeeper()->tryMulti(requests, responses);
556 if (code == Coordination::Error::ZOK)
557 {
558 LOG_INFO(log, "Processed requests on rollback {}", requests.size());
559 }
560 else
561 {
562 zkutil::KeeperMultiException exception(code, requests, responses);
563 if (Coordination::isHardwareError(code))
564 LOG_WARNING(
565 log, "Failed to process requests on rollback {} because of {}", requests.size(), Coordination::toString(code));
566 else
567 LOG_WARNING(
568 log,
569 "Failed to process requests on rollback {} because of {} on path {}",
570 requests.size(),
571 Coordination::toString(code),
572 exception.getPathForFirstFailedOp());
573 }
574 }
575 }
576
577 {
578 std::lock_guard lock{running_list_mutex};
579 bool removed = running_list.erase(txn->tid.getHash());
580 if (!removed)
581 abort();
582 snapshots_in_use.erase(txn->snapshot_in_use_it);
583 }
584
585 tryWriteEventToSystemLog(log, global_context, TransactionsInfoLogElement::ROLLBACK, txn->tid);
586 txn->afterFinalize();
587}
588
589MergeTreeTransactionPtr TransactionLog::tryGetRunningTransaction(const TIDHash & tid)
590{

Callers 4

killMutationMethod · 0.80
executeRollbackMethod · 0.80
onDestroyMethod · 0.80
onExceptionMethod · 0.80

Calls 14

getCurrentExceptionCodeFunction · 0.85
isHardwareErrorFunction · 0.85
getRequestsOnRollbackMethod · 0.80
afterFinalizeMethod · 0.80
formatFunction · 0.70
toStringFunction · 0.70
tryWriteEventToSystemLogFunction · 0.70
rollbackMethod · 0.45
emptyMethod · 0.45
tryMultiMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected