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

Method precommit

src/Transaction/CnchServerTransaction.cpp:189–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189void CnchServerTransaction::precommit()
190{
191 LOG_DEBUG(log, "Transaction {} starts pre commit\n", txn_record.txnID().toUInt64());
192 Stopwatch watch(CLOCK_MONOTONIC_COARSE);
193 SCOPE_EXIT({ ProfileEvents::increment(ProfileEvents::CnchTxnPrecommitElapsedMilliseconds, watch.elapsedMilliseconds()); });
194
195 {
196 auto lock = getLock();
197 if (auto status = getStatus(); status != CnchTransactionStatus::Running)
198 throw Exception("Transaction is not in running status, but in " + String(txnStatusToString(status)), ErrorCodes::LOGICAL_ERROR);
199
200 for (auto & action : actions)
201 action->executeV2();
202
203 txn_record.prepared = true;
204 action_size_before_dedup = actions.size();
205 }
206
207 auto retry_time = getContext()->getSettingsRef().max_dedup_retry_time.value;
208 do
209 {
210 try
211 {
212 executeDedupStage();
213 assertLockAcquired();
214 }
215 catch (...)
216 {
217 if (retry_time == 0)
218 throw;
219 else if (action_size_before_dedup < actions.size())
220 {
221 /// TODO: Impl retry in this case, especially handle undo buffer
222 LOG_WARNING(
223 log,
224 "Dedup stage failed, but result is not empty({}/{}), unable to retry, retry time: {}",
225 actions.size(),
226 action_size_before_dedup,
227 retry_time);
228 throw;
229 }
230 else
231 {
232 LOG_WARNING(log, "Dedup stage failed, retry time: {}, reason: {}", retry_time, getCurrentExceptionMessage(false));
233 retry_time--;
234 dedup_stage_flag = false;
235 continue;
236 }
237 }
238 break;
239 } while (true);
240}
241
242void CnchServerTransaction::executeDedupStage()
243{

Callers

nothing calls this directly

Calls 11

getLockFunction · 0.85
txnStatusToStringFunction · 0.85
toUInt64Method · 0.80
incrementFunction · 0.50
ExceptionClass · 0.50
StringClass · 0.50
txnIDMethod · 0.45
elapsedMillisecondsMethod · 0.45
executeV2Method · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected