| 572 | } |
| 573 | |
| 574 | static void |
| 575 | doNotifyingCommitPrepared(void) |
| 576 | { |
| 577 | bool succeeded; |
| 578 | int retry = 0; |
| 579 | volatile int savedInterruptHoldoffCount; |
| 580 | MemoryContext oldcontext = CurrentMemoryContext;; |
| 581 | time_t retry_time_start; |
| 582 | bool retry_timedout; |
| 583 | XLogRecPtr recptr; |
| 584 | |
| 585 | elog(DTM_DEBUG5, "doNotifyingCommitPrepared entering in state = %s", DtxStateToString(MyTmGxactLocal->state)); |
| 586 | |
| 587 | Assert(MyTmGxactLocal->state == DTX_STATE_INSERTED_COMMITTED); |
| 588 | setCurrentDtxState(DTX_STATE_NOTIFYING_COMMIT_PREPARED); |
| 589 | |
| 590 | SIMPLE_FAULT_INJECTOR("dtm_broadcast_commit_prepared"); |
| 591 | |
| 592 | /* |
| 593 | * Acquire TwophaseCommitLock in shared mode to block any GPDB restore |
| 594 | * points from being created while commit prepared messages are being |
| 595 | * broadcasted. |
| 596 | */ |
| 597 | LWLockAcquire(TwophaseCommitLock, LW_SHARED); |
| 598 | |
| 599 | savedInterruptHoldoffCount = InterruptHoldoffCount; |
| 600 | |
| 601 | Assert(MyTmGxactLocal->dtxSegments != NIL); |
| 602 | PG_TRY(); |
| 603 | { |
| 604 | succeeded = currentDtxDispatchProtocolCommand(DTX_PROTOCOL_COMMAND_COMMIT_PREPARED, true); |
| 605 | } |
| 606 | PG_CATCH(); |
| 607 | { |
| 608 | /* |
| 609 | * restore the previous value, which is reset to 0 in errfinish. |
| 610 | */ |
| 611 | MemoryContextSwitchTo(oldcontext); |
| 612 | InterruptHoldoffCount = savedInterruptHoldoffCount; |
| 613 | succeeded = false; |
| 614 | FlushErrorState(); |
| 615 | } |
| 616 | PG_END_TRY(); |
| 617 | |
| 618 | if (!succeeded) |
| 619 | { |
| 620 | Assert(MyTmGxactLocal->state == DTX_STATE_NOTIFYING_COMMIT_PREPARED); |
| 621 | ereport(DTM_DEBUG5, |
| 622 | (errmsg("marking retry needed for distributed transaction " |
| 623 | "'Commit Prepared' broadcast to the segments"), |
| 624 | TM_ERRDETAIL)); |
| 625 | |
| 626 | setCurrentDtxState(DTX_STATE_RETRY_COMMIT_PREPARED); |
| 627 | setDistributedTransactionContext(DTX_CONTEXT_QD_RETRY_PHASE_2); |
| 628 | } |
| 629 | |
| 630 | retry_timedout = (dtx_phase2_retry_second == 0) ? true : false; |
| 631 | retry_time_start = time(NULL); |
no test coverage detected