|
79 | 79 | #include "pgxc/pgxc.h"
|
80 | 80 | #include "access/gtm.h"
|
81 | 81 | #include "storage/ipc.h"
|
| 82 | +#include "utils/guc.h" |
82 | 83 | /* PGXC_DATANODE */
|
83 | 84 | #include "postmaster/autovacuum.h"
|
84 | 85 | #endif
|
@@ -219,6 +220,10 @@ static TransactionId KnownAssignedXidsGetOldestXmin(void);
|
219 | 220 | static void KnownAssignedXidsDisplay(int trace_level);
|
220 | 221 | static void KnownAssignedXidsReset(void);
|
221 | 222 |
|
| 223 | +#ifdef XCP |
| 224 | +int GlobalSnapshotSource; |
| 225 | +#endif |
| 226 | + |
222 | 227 | /*
|
223 | 228 | * Report shared-memory space needed by CreateSharedProcArray.
|
224 | 229 | */
|
@@ -1508,22 +1513,35 @@ GetSnapshotData(Snapshot snapshot)
|
1508 | 1513 |
|
1509 | 1514 | #ifdef PGXC /* PGXC_DATANODE */
|
1510 | 1515 | /*
|
1511 |
| - * Obtain a global snapshot for a Postgres-XC session |
1512 |
| - * if possible. |
1513 |
| - */ |
1514 |
| - if (GetPGXCSnapshotData(snapshot)) |
1515 |
| - return snapshot; |
1516 |
| - /* |
1517 |
| - * We only make one exception for using local snapshot and that's the |
1518 |
| - * initdb time. When IsPostmasterEnvironment is true, snapshots must either |
1519 |
| - * be pushed down from the coordinator or directly obtained from the |
1520 |
| - * GTM. |
1521 |
| - * |
1522 |
| - * !!TODO We don't seem to fully support Hot Standby. So why should we even |
1523 |
| - * exempt RecoveryInProgress()? |
1524 |
| - */ |
1525 |
| - if (IsPostmasterEnvironment && !useLocalXid) |
1526 |
| - elog(ERROR, "Was unable to obtain a snapshot from GTM."); |
| 1516 | + * If the user has chosen to work with a coordinator-local snapshot, just |
| 1517 | + * compute snapshot locally. This can have adverse effects on the global |
| 1518 | + * consistency, in a multi-coordinator environment, but also in a |
| 1519 | + * single-coordinator setup because our recent changes to transaction |
| 1520 | + * management now allows datanodes to start global snapshots or more |
| 1521 | + * precisely attach current transaction to a global transaction. But users |
| 1522 | + * may still want to use this model for performance of their XL cluster, at |
| 1523 | + * the cost of reduced global consistency |
| 1524 | + */ |
| 1525 | + if (GlobalSnapshotSource == GLOBAL_SNAPSHOT_SOURCE_GTM) |
| 1526 | + { |
| 1527 | + /* |
| 1528 | + * Obtain a global snapshot for a Postgres-XC session |
| 1529 | + * if possible. |
| 1530 | + */ |
| 1531 | + if (GetPGXCSnapshotData(snapshot)) |
| 1532 | + return snapshot; |
| 1533 | + /* |
| 1534 | + * We only make one exception for using local snapshot and that's the |
| 1535 | + * initdb time. When IsPostmasterEnvironment is true, snapshots must |
| 1536 | + * either be pushed down from the coordinator or directly obtained from |
| 1537 | + * the GTM. |
| 1538 | + * |
| 1539 | + * !!TODO We don't seem to fully support Hot Standby. So why should we |
| 1540 | + * even exempt RecoveryInProgress()? |
| 1541 | + */ |
| 1542 | + if (IsPostmasterEnvironment && !useLocalXid) |
| 1543 | + elog(ERROR, "Was unable to obtain a snapshot from GTM."); |
| 1544 | + } |
1527 | 1545 | #endif
|
1528 | 1546 |
|
1529 | 1547 | /*
|
@@ -3254,8 +3272,6 @@ GetSnapshotFromGlobalSnapshot(Snapshot snapshot)
|
3254 | 3272 | globalSnapshot.snapshot_source == SNAPSHOT_DIRECT)
|
3255 | 3273 | && TransactionIdIsValid(globalSnapshot.gxmin))
|
3256 | 3274 | {
|
3257 |
| - int index; |
3258 |
| - ProcArrayStruct *arrayP = procArray; |
3259 | 3275 | TransactionId global_xmin;
|
3260 | 3276 |
|
3261 | 3277 | snapshot->xmin = globalSnapshot.gxmin;
|
@@ -4360,7 +4376,6 @@ ProcArrayCheckXminConsistency(TransactionId global_xmin)
|
4360 | 4376 | for (index = 0; index < arrayP->numProcs; index++)
|
4361 | 4377 | {
|
4362 | 4378 | int pgprocno = arrayP->pgprocnos[index];
|
4363 |
| - volatile PGPROC *proc = &allProcs[pgprocno]; |
4364 | 4379 | volatile PGXACT *pgxact = &allPgXact[pgprocno];
|
4365 | 4380 | TransactionId xid;
|
4366 | 4381 |
|
|
0 commit comments