1
- sisva /*
1
+ /*
2
2
* pg_dtm.c
3
3
*
4
4
* Pluggable distributed transaction manager
@@ -59,7 +59,7 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
59
59
static void DtmUpdateRecentXmin (void );
60
60
static void DtmInitialize (void );
61
61
static void DtmXactCallback (XactEvent event , void * arg );
62
- static void DtmGetNextXid (void );
62
+ static TransactionId DtmGetNextXid (void );
63
63
64
64
static bool TransactionIdIsInDtmSnapshot (TransactionId xid );
65
65
static bool TransactionIdIsInDoubt (TransactionId xid );
<
10000
path d="M7.823 1.677 4.927 4.573A.25.25 0 0 0 5.104 5H7.25v3.236a.75.75 0 1 0 1.5 0V5h2.146a.25.25 0 0 0 .177-.427L8.177 1.677a.25.25 0 0 0-.354 0ZM13.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Zm-3.75.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM7.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5ZM4 11.75a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1-.75-.75ZM1.75 11a.75.75 0 0 0 0 1.5h.5a.75.75 0 0 0 0-1.5h-.5Z"> @@ -115,9 +115,9 @@ static bool TransactionIdIsInDoubt(TransactionId xid)
115
115
bool inDoubt ;
116
116
117
117
if (!TransactionIdIsInDtmSnapshot (xid )) {
118
- LWLockAcquire (dtm -> lock , LW_SHARED );
118
+ LWLockAcquire (dtm -> hashLock , LW_SHARED );
119
119
inDoubt = hash_search (xid_in_doubt , & xid , HASH_FIND , NULL ) != NULL ;
120
- LWLockRelease (dtm -> lock );
120
+ LWLockRelease (dtm -> hashLock );
121
121
if (!inDoubt ) {
122
122
XLogRecPtr lsn ;
123
123
inDoubt = CLOGTransactionIdGetStatus (xid , & lsn ) != TRANSACTION_STATUS_IN_PROGRESS ;
@@ -285,10 +285,9 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
285
285
{
286
286
XTM_TRACE ("XTM: DtmSetTransactionStatus %u = %u \n" , xid , status );
287
287
if (!RecoveryInProgress ()) {
288
- if (DtmGlobalTransaction ) {
288
+ if (TransactionIdIsValid ( DtmNextXid ) ) {
289
289
/* Already should be IN_PROGRESS */
290
290
/* CLOGTransactionIdSetTreeStatus(xid, nsubxids, subxids, TRANSACTION_STATUS_IN_PROGRESS, lsn); */
291
- DtmGlobalTransaction = false;
292
291
CurrentTransactionSnapshot = NULL ;
293
292
if (status == TRANSACTION_STATUS_ABORTED ) {
294
293
CLOGTransactionIdSetTreeStatus (xid , nsubxids , subxids , status , lsn );
@@ -300,9 +299,7 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
300
299
LWLockAcquire (dtm -> hashLock , LW_EXCLUSIVE );
301
300
hash_search (xid_in_doubt , & DtmNextXid , HASH_ENTER , NULL );
302
301
LWLockRelease (dtm -> hashLock );
303
- if (!DtmGlobalSetTransStatus (xid , status , true)) {
304
- elog (ERROR , "DTMD failed to set transaction status" );
305
- }
302
+ DtmGlobalSetTransStatus (xid , status , true);
306
303
XTM_INFO ("Commit transaction %d\n" , xid );
307
304
}
308
305
} else {
@@ -370,6 +367,9 @@ DtmXactCallback(XactEvent event, void *arg)
370
367
/* no break */
371
368
case XACT_EVENT_ABORT :
372
369
DtmNextXid = InvalidTransactionId ;
370
+ break ;
371
+ default :
372
+ break ;
373
373
}
374
374
}
375
375
}
@@ -466,7 +466,7 @@ dtm_get_current_snapshot_xmax(PG_FUNCTION_ARGS)
466
466
Datum
467
467
dtm_begin_transaction (PG_FUNCTION_ARGS )
468
468
{
469
- int nPaticipants = PG_GETARG_INT32 (0 );
469
+ int nParticipants = PG_GETARG_INT32 (0 );
470
470
Assert (!TransactionIdIsValid (DtmNextXid ));
471
471
472
472
DtmNextXid = DtmGlobalStartTransaction (nParticipants , & DtmSnapshot );
0 commit comments