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.
| 177 | // destructed when a transaction throws an exception, while we need to roll back the active |
| 178 | // transaction still. |
| 179 | void 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 | |
| 198 | void TransactionManager::checkpoint(main::ClientContext& clientContext) { |
| 199 | if (clientContext.isInMemory()) { |
no test coverage detected