From 1697e7b31914d80fee57fbe2c1fe4d15907017a0 Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Wed, 13 Sep 2023 08:56:03 +0300 Subject: [PATCH] Fix lfc_ensure_function which now disables LFC (#5294) ## Problem There was a bug in lfc_ensure_opened which actually disables LFC ## Summary of changes Return true ifLFC file is normally opened ## Checklist before requesting a review - [ ] I have performed a self-review of my code. - [ ] If it is a core feature, I have added thorough tests. - [ ] Do we need to implement analytics? if so did you add the relevant metrics to the dashboard? - [ ] If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section. ## Checklist before merging - [ ] Do not forget to reformat commit message to not include the above checklist Co-authored-by: Konstantin Knizhnik --- pgxn/neon/file_cache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pgxn/neon/file_cache.c b/pgxn/neon/file_cache.c index 2c0d5b0c4f..6e5c0e0f38 100644 --- a/pgxn/neon/file_cache.c +++ b/pgxn/neon/file_cache.c @@ -153,7 +153,7 @@ lfc_ensure_opened(void) return false; } } - return false; + return true; } static void @@ -640,6 +640,7 @@ lfc_write(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber blkno, rc = pwrite(lfc_desc, buffer, BLCKSZ, ((off_t)entry->offset*BLOCKS_PER_CHUNK + chunk_offs)*BLCKSZ); if (rc != BLCKSZ) { + LWLockRelease(lfc_lock); lfc_disable("write"); } else @@ -650,9 +651,8 @@ lfc_write(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber blkno, dlist_push_tail(&lfc_ctl->lru, &entry->lru_node); entry->bitmap[chunk_offs >> 5] |= (1 << (chunk_offs & 31)); + LWLockRelease(lfc_lock); } - - LWLockRelease(lfc_lock); } /*