diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d4c344cc..b945d823c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ accidentally triggering the load of a previous DB version.** * #5410 Fix file trailer handling in the COPY fetcher * #5233 Out of on_proc_exit slots on guc license change * #5427 Handle user-defined FDW options properly +* #5428 Use consistent snapshots when scanning metadata * #5442 Decompression may have lost DEFAULT values * #5446 Add checks for malloc failure in libpq calls diff --git a/src/scanner.c b/src/scanner.c index e04241e72..a1887b9c0 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -221,6 +221,20 @@ prepare_scan(ScannerCtx *ctx) */ MemoryContext oldmcxt = MemoryContextSwitchTo(ctx->internal.scan_mcxt); ctx->snapshot = RegisterSnapshot(GetSnapshotData(SnapshotSelf)); + /* + * Invalidate the PG catalog snapshot to ensure it is refreshed and + * up-to-date with the snapshot used to scan TimescaleDB + * metadata. Since TimescaleDB metadata is often joined with PG + * catalog data (e.g., calling get_relname_relid() to fill in chunk + * table Oid), this avoids any potential problems where the different + * snapshots used to scan TimescaleDB metadata and PG catalog metadata + * aren't in sync. + * + * Ideally, a catalog snapshot would be used to scan TimescaleDB + * metadata, but that will change the behavior of chunk creation in + * SERIALIZED mode, as described above. + */ + InvalidateCatalogSnapshot(); ctx->internal.registered_snapshot = true; MemoryContextSwitchTo(oldmcxt); }