Skip to content

Commit 7d7a547

Browse files
knizhnikMMeent
authored andcommitted
Do not produce open file error for unlogged relations (#239)
1 parent 03fc551 commit 7d7a547

File tree

1 file changed

+7
-1
lines changed
  • src/backend/storage/smgr

1 file changed

+7
-1
lines changed

src/backend/storage/smgr/md.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,13 @@ mdnblocks(SMgrRelation reln, ForkNumber forknum)
775775
BlockNumber nblocks;
776776
BlockNumber segno;
777777

778-
mdopenfork(reln, forknum, EXTENSION_FAIL);
778+
/* NEON: md smgr is used in Neon for unlogged and temp relations.
779+
* After compute node restart their data is deleted but unlogged tables are still present in system catalog.
780+
* This is a difference with Vanilla Postgres where unlogged relations are truncated only after abnormal termination.
781+
* To avoid "could not open file" we have to use EXTENSION_RETURN_NULL hear instead of EXTENSION_FAIL
782+
*/
783+
if (!mdopenfork(reln, forknum, RelFileNodeBackendIsTemp(reln->smgr_rnode) ? EXTENSION_FAIL : EXTENSION_RETURN_NULL))
784+
return 0;
779785

780786
/* mdopen has opened the first segment */
781787
Assert(reln->md_num_open_segs[forknum] > 0);

0 commit comments

Comments
 (0)