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 );
@@ -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