MCPcopy Create free account
hub / github.com/ByConity/ByConity / commitV1

Method commitV1

src/Transaction/CnchServerTransaction.cpp:105–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103
104
105TxnTimestamp CnchServerTransaction::commitV1()
106{
107 LOG_DEBUG(log, "Transaction {} starts commit (v1 api)\n", txn_record.txnID().toUInt64());
108
109 if (isReadOnly())
110 throw Exception("Invalid commit operation for read only transaction", ErrorCodes::LOGICAL_ERROR);
111
112 Stopwatch watch(CLOCK_MONOTONIC_COARSE);
113 SCOPE_EXIT({
114 ProfileEvents::increment((getStatus() == CnchTransactionStatus::Finished ? ProfileEvents::CnchTxnCommitted : ProfileEvents::CnchTxnCommitV1Failed));
115 ProfileEvents::increment(ProfileEvents::CnchTxnCommitV1ElapsedMilliseconds, watch.elapsedMilliseconds());
116 });
117
118 auto commit_ts = global_context->getTimestamp();
119
120 try
121 {
122 auto lock = getLock();
123 for (const auto & action : actions)
124 {
125 action->executeV1(commit_ts);
126 }
127
128 setStatus(CnchTransactionStatus::Finished);
129 setCommitTime(commit_ts);
130 LOG_DEBUG(log, "Successfully committed transaction (v1 api): {}\n", txn_record.txnID().toUInt64());
131 commitModifiedCount(this->modified_counter);
132 return commit_ts;
133 }
134 catch (...)
135 {
136 rollbackV1(commit_ts);
137 throw;
138 }
139}
140
141void CnchServerTransaction::rollbackV1(const TxnTimestamp & ts)
142{

Callers 15

alterMethod · 0.45
alterMethod · 0.45
mutateMethod · 0.45
alterMethod · 0.45
alterMethod · 0.45
alterMethod · 0.45
createTableMethod · 0.45
dropTableMethod · 0.45
dropMethod · 0.45
renameDatabaseMethod · 0.45

Calls 9

getLockFunction · 0.85
commitModifiedCountFunction · 0.85
toUInt64Method · 0.80
ExceptionClass · 0.50
incrementFunction · 0.50
txnIDMethod · 0.45
elapsedMillisecondsMethod · 0.45
getTimestampMethod · 0.45
executeV1Method · 0.45

Tested by

no test coverage detected