From 17a1e68a636edd87a34acf34dace2a696af81a2d Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 21 Jun 2024 01:45:53 +0300 Subject: [PATCH 1/1] Fix relcache invalidation when relfilelocator is updated In commit af0e7deb4a, I removed this call to RelationCloseSmgr(), because the dangling SMgrRelation was no longer an issue. However, we still need to call in case the relation's relfilelocator has changed, so that we open the new relfile on the next access. Reported-by: Alexander Lakhin Discussion: https://www.postgresql.org/message-id/987b1c8c-8c91-4847-ca0e-879f421680ff%40gmail.com --- src/backend/utils/cache/relcache.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 35dbb87ae3..f45880d96d 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -3032,6 +3032,9 @@ RelationCacheInvalidate(bool debug_discard) { relation = idhentry->reldesc; + /* Close all smgr references, in case the relfilelocator has changed */ + RelationCloseSmgr(relation); + /* * Ignore new relations; no other backend will manipulate them before * we commit. Likewise, before replacing a relation's relfilelocator, -- 2.39.2