MCPcopy Create free account
hub / github.com/apache/cloudberry / performDtxProtocolCommand

Function performDtxProtocolCommand

src/backend/cdb/cdbtm.c:2220–2421  ·  view source on GitHub ↗

* On the QE, handle a DtxProtocolCommand */

Source from the content-addressed store, hash-verified

2218 * On the QE, handle a DtxProtocolCommand
2219 */
2220void
2221performDtxProtocolCommand(DtxProtocolCommand dtxProtocolCommand,
2222 const char *gid,
2223 DtxContextInfo *contextInfo)
2224{
2225 elog(DTM_DEBUG5,
2226 "performDtxProtocolCommand called with DTX protocol = %s, segment distribute transaction context: '%s'",
2227 DtxProtocolCommandToString(dtxProtocolCommand), DtxContextToString(DistributedTransactionContext));
2228
2229 switch (dtxProtocolCommand)
2230 {
2231 case DTX_PROTOCOL_COMMAND_ABORT_NO_PREPARED:
2232 elog(DTM_DEBUG5,
2233 "performDtxProtocolCommand going to call AbortOutOfAnyTransaction for distributed transaction %s", gid);
2234 AbortOutOfAnyTransaction();
2235 break;
2236
2237 case DTX_PROTOCOL_COMMAND_PREPARE:
2238 case DTX_PROTOCOL_COMMAND_COMMIT_ONEPHASE:
2239
2240 /*
2241 * The QD has directed us to read-only commit or prepare an
2242 * implicit or explicit distributed transaction.
2243 */
2244 switch (DistributedTransactionContext)
2245 {
2246 case DTX_CONTEXT_LOCAL_ONLY:
2247
2248 /*
2249 * Spontaneously aborted while we were back at the QD?
2250 */
2251 elog(ERROR, "Distributed transaction %s not found", gid);
2252 break;
2253
2254 case DTX_CONTEXT_QE_TWO_PHASE_EXPLICIT_WRITER:
2255 case DTX_CONTEXT_QE_TWO_PHASE_IMPLICIT_WRITER:
2256 if (dtxProtocolCommand == DTX_PROTOCOL_COMMAND_COMMIT_ONEPHASE)
2257 performDtxProtocolCommitOnePhase(gid);
2258 else
2259 performDtxProtocolPrepare(gid);
2260 break;
2261
2262 case DTX_CONTEXT_QD_DISTRIBUTED_CAPABLE:
2263 case DTX_CONTEXT_QD_RETRY_PHASE_2:
2264 case DTX_CONTEXT_QE_PREPARED:
2265 case DTX_CONTEXT_QE_FINISH_PREPARED:
2266 case DTX_CONTEXT_QE_ENTRY_DB_SINGLETON:
2267 case DTX_CONTEXT_QE_READER:
2268 elog(FATAL, "Unexpected segment distribute transaction context: '%s'",
2269 DtxContextToString(DistributedTransactionContext));
2270 break;
2271
2272 default:
2273 elog(PANIC, "Unexpected segment distribute transaction context value: %d",
2274 (int) DistributedTransactionContext);
2275 break;
2276 }
2277 break;

Callers 1

Tested by

no test coverage detected