Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9226662

Browse files
committed
Add comments to DTM
1 parentc2f8668 commit9226662

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

‎contrib/pg_xtm/pg_dtm.c‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ typedef struct
5555

5656
#defineDTM_SHMEM_SIZE (1024*1024)
5757
#defineDTM_HASH_SIZE 1003
58-
#defineXTM_CONNECT_ATTEMPTS 10
59-
6058

6159
void_PG_init(void);
6260
void_PG_fini(void);
@@ -79,7 +77,7 @@ static TransactionId DtmGetGlobalTransactionId(void);
7977
staticboolTransactionIdIsInSnapshot(TransactionIdxid,Snapshotsnapshot);
8078
staticboolTransactionIdIsInDoubt(TransactionIdxid);
8179

82-
staticvoiddtm_shmem_startup(void);
80+
staticvoidDtmShmemStartup(void);
8381

8482
staticshmem_startup_hook_typeprev_shmem_startup_hook;
8583
staticHTAB*xid_in_doubt;
@@ -121,18 +119,27 @@ static void DumpSnapshot(Snapshot s, char *name)
121119
XTM_INFO("%s\n",buf);
122120
}
123121

122+
/* In snapshots provided by DTMD xip array is sorted, so we can use bsearch */
124123
staticboolTransactionIdIsInSnapshot(TransactionIdxid,Snapshotsnapshot)
125124
{
126125
returnxid >=snapshot->xmax
127126
||bsearch(&xid,snapshot->xip,snapshot->xcnt,sizeof(TransactionId),xidComparator)!=NULL;
128127
}
129128

130-
129+
/* Transaction is considered as in-doubt if it is globally committed by DTMD but local commit is not yet completed.
130+
* It can happen because we report DTMD about transaction commit in SetTransactionStatus, which is called inside commit
131+
* after saving transaction state in WAL but before releasing locks. So DTMD can include this transaction in snapshot
132+
* before local commit is completed and transaction is marked as completed in local CLOG.
133+
*
134+
* We use xid_in_doubt hash table to mark transactions which are "precommitted". Entry is inserted in hash table
135+
* before seding status to DTMD and removed after receving response from DTMD and setting transaction status in local CLOG.
136+
* So information about transaction should always present either in xid_in_doubt either in CLOG.
137+
*/
131138
staticboolTransactionIdIsInDoubt(TransactionIdxid)
132139
{
133140
boolinDoubt;
134141

135-
if (!TransactionIdIsInSnapshot(xid,&DtmSnapshot)) {
142+
if (!TransactionIdIsInSnapshot(xid,&DtmSnapshot)) {/* transaction is completed according to the snaphot */
136143
LWLockAcquire(dtm->hashLock,LW_SHARED);
137144
inDoubt=hash_search(xid_in_doubt,&xid,HASH_FIND,NULL)!=NULL;
138145
LWLockRelease(dtm->hashLock);
@@ -740,7 +747,7 @@ _PG_init(void)
740747
* Install hooks.
741748
*/
742749
prev_shmem_startup_hook=shmem_startup_hook;
743-
shmem_startup_hook=dtm_shmem_startup;
750+
shmem_startup_hook=DtmShmemStartup;
744751
}
745752

746753
/*
@@ -753,7 +760,7 @@ _PG_fini(void)
753760
}
754761

755762

756-
staticvoiddtm_shmem_startup(void)
763+
staticvoidDtmShmemStartup(void)
757764
{
758765
if (prev_shmem_startup_hook) {
759766
prev_shmem_startup_hook();

‎src/backend/storage/ipc/procarray.c‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,19 +1003,6 @@ TransactionIdIsRunning(TransactionId xid)
10031003
TransactionIdtopxid;
10041004
inti,
10051005
j;
1006-
1007-
if (VisibilityCallback)
1008-
{
1009-
/* Just wait for in-doubt transactions */
1010-
(*VisibilityCallback)(xid);
1011-
/*
1012-
if (result != XID_IN_DOUBT)
1013-
{
1014-
return result == XID_INVISIBLE;
1015-
}
1016-
*/
1017-
}
1018-
10191006
/*
10201007
* Don't bother checking a transaction older than RecentXmin; it could not
10211008
* possibly still be running. (Note: in particular, this guarantees that

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp