This is just what's hit by the tests. It's not an actual fix.
#include "utils/inval.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
+#include "utils/snapmgr.h"
#include "utils/syscache.h"
#include "utils/varlena.h"
{
if (OidIsValid(myTempNamespace)) /* should always be true */
{
+ Snapshot snap;
+
/* Need to ensure we have a usable transaction. */
AbortOutOfAnyTransaction();
StartTransactionCommand();
+ /* ensure xmin stays set */
+ snap = RegisterSnapshot(GetCatalogSnapshot(InvalidOid));
+
RemoveTempRelations(myTempNamespace);
+ UnregisterSnapshot(snap);
CommitTransactionCommand();
}
}
#include "utils/fmgroids.h"
#include "utils/pg_lsn.h"
#include "utils/rel.h"
+#include "utils/snapmgr.h"
#include "utils/syscache.h"
static List *textarray_to_stringlist(ArrayType *textarray);
bool nulls[Natts_pg_subscription_rel];
Datum values[Natts_pg_subscription_rel];
bool replaces[Natts_pg_subscription_rel];
+ Snapshot snap = RegisterSnapshot(GetCatalogSnapshot(InvalidOid));
LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
/* Cleanup. */
table_close(rel, NoLock);
+
+ UnregisterSnapshot(snap);
}
/*
char *relationName = NULL;
char *relationNamespace = NULL;
PGRUsage ru0;
+ Snapshot snap;
/*
* Create a memory context that will survive forced transaction commits we
*/
StartTransactionCommand();
+ snap = RegisterSnapshot(GetCatalogSnapshot(InvalidOid));
forboth(lc, indexIds, lc2, newIndexIds)
{
}
/* Commit this transaction and make index swaps visible */
+ UnregisterSnapshot(snap);
CommitTransactionCommand();
+
StartTransactionCommand();
+ snap = RegisterSnapshot(GetCatalogSnapshot(InvalidOid));
/*
* Phase 5 of REINDEX CONCURRENTLY
}
/* Commit this transaction to make the updates visible. */
+ UnregisterSnapshot(snap);
CommitTransactionCommand();
+
StartTransactionCommand();
/*
WaitForLockersMultiple(lockTags, AccessExclusiveLock, true);
PushActiveSnapshot(GetTransactionSnapshot());
+ snap = RegisterSnapshot(GetCatalogSnapshot(InvalidOid));
{
ObjectAddresses *objects = new_object_addresses();
}
PopActiveSnapshot();
+ UnregisterSnapshot(snap);
CommitTransactionCommand();
/*
ListCell *l;
List *oids_to_truncate = NIL;
List *oids_to_drop = NIL;
+ Snapshot snap;
foreach(l, on_commits)
{
}
}
+ if (oids_to_truncate == NIL && oids_to_drop == NIL)
+ return;
+
+ snap = RegisterSnapshot(GetCatalogSnapshot(InvalidOid));
+
/*
* Truncate relations before dropping so that all dependencies between
* relations are removed after they are worked on. Doing it like this
}
#endif
}
+
+ UnregisterSnapshot(snap);
}
/*
{
Relation rel;
WalRcvExecResult *res;
+ Snapshot snap;
SpinLockAcquire(&MyLogicalRepWorker->relmutex);
MyLogicalRepWorker->relstate = SUBREL_STATE_DATASYNC;
/* Update the state and make it visible to others. */
StartTransactionCommand();
+ snap = RegisterSnapshot(GetCatalogSnapshot(InvalidOid));
+
UpdateSubscriptionRelState(MyLogicalRepWorker->subid,
MyLogicalRepWorker->relid,
MyLogicalRepWorker->relstate,
MyLogicalRepWorker->relstate_lsn);
+
+ UnregisterSnapshot(snap);
CommitTransactionCommand();
pgstat_report_stat(false);
CRS_USE_SNAPSHOT, origin_startpos);
PushActiveSnapshot(GetTransactionSnapshot());
+ snap = RegisterSnapshot(GetCatalogSnapshot(InvalidOid));
copy_table(rel);
PopActiveSnapshot();
/* Make the copy visible. */
CommandCounterIncrement();
+ UnregisterSnapshot(snap);
+
/*
* We are done with the initial data synchronization, update
* the state.
*/
if (*origin_startpos >= MyLogicalRepWorker->relstate_lsn)
{
+ snap = RegisterSnapshot(GetCatalogSnapshot(InvalidOid));
+
/*
* Update the new state in catalog. No need to bother
* with the shmem state as we are exiting for good.
MyLogicalRepWorker->relid,
SUBREL_STATE_SYNCDONE,
*origin_startpos);
+ UnregisterSnapshot(snap);
+
finish_sync_worker();
}
break;
ensure_transaction();
+ /* catalog modifications need a set snapshot */
+ PushActiveSnapshot(GetTransactionSnapshot());
+
remote_relids = logicalrep_read_truncate(s, &cascade, &restart_seqs);
foreach(lc, remote_relids)
}
CommandCounterIncrement();
+ PopActiveSnapshot();
}
Snapshot
GetCatalogSnapshot(Oid relid)
{
+ Assert(IsTransactionState());
+
/*
* Return historic snapshot while we're doing logical decoding, so we can
* see the appropriate state of the catalog.
if (pairingheap_is_empty(&RegisteredSnapshots))
{
MyPgXact->xmin = InvalidTransactionId;
+ TransactionXmin = InvalidTransactionId;
+ RecentXmin = InvalidTransactionId;
return;
}