MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / rollback

Method rollback

src/transaction/transaction_manager.cpp:179–196  ·  view source on GitHub ↗

Note: We take in additional `transaction` here is due to that `transactionContext` might be destructed when a transaction throws an exception, while we need to roll back the active transaction still.

Source from the content-addressed store, hash-verified

177// destructed when a transaction throws an exception, while we need to roll back the active
178// transaction still.
179void TransactionManager::rollback(main::ClientContext& clientContext, Transaction* transaction) {
180 std::unique_lock lck{mtxForSerializingPublicFunctionCalls};
181 clientContext.cleanUp();
182 switch (transaction->getType()) {
183 case TransactionType::READ_ONLY: {
184 clearTransactionNoLock(transaction->getID());
185 } break;
186 case TransactionType::RECOVERY:
187 case TransactionType::WRITE: {
188 transaction->rollback(&wal);
189 clearTransactionNoLock(transaction->getID());
190 activeWriteTransactionCount.fetch_sub(1, std::memory_order_release);
191 } break;
192 default: {
193 throw TransactionManagerException("Invalid transaction type to rollback.");
194 }
195 }
196}
197
198void TransactionManager::checkpoint(main::ClientContext& clientContext) {
199 if (clientContext.isInMemory()) {

Callers 1

checkpointNoLockMethod · 0.45

Calls 2

cleanUpMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected