Skip hole tags in local_cache view (#11454)

## Problem

If the local file cache is shrunk, so that we punch some holes in the
underlying file, the local_cache view displays the holes incorrectly.
See https://github.com/neondatabase/neon/issues/10770

## Summary of changes

Skip hole tags in the local_cache view.

---------

Co-authored-by: Konstantin Knizhnik <knizhnik@neon.tech>
This commit is contained in:
Konstantin Knizhnik
2025-04-08 06:52:50 +03:00
committed by GitHub
parent 0875dacce0
commit b2a0b2e9dd
2 changed files with 40 additions and 11 deletions

View File

@@ -49,6 +49,8 @@ def test_lfc_resize(neon_simple_env: NeonEnv, pg_bin: PgBin):
conn = endpoint.connect()
cur = conn.cursor()
cur.execute("create extension neon")
def get_lfc_size() -> tuple[int, int]:
lfc_file_path = endpoint.lfc_path()
lfc_file_size = lfc_file_path.stat().st_size
@@ -103,3 +105,23 @@ def test_lfc_resize(neon_simple_env: NeonEnv, pg_bin: PgBin):
time.sleep(1)
assert int(lfc_file_blocks) <= 128 * 1024
# Now test that number of rows returned by local_cache is the same as file_cache_used_pages.
# Perform several iterations to make cache cache content stabilized.
nretries = 10
while True:
cur.execute("select count(*) from local_cache")
local_cache_size = cur.fetchall()[0][0]
cur.execute(
"select lfc_value::bigint FROM neon_lfc_stats where lfc_key='file_cache_used_pages'"
)
used_pages = cur.fetchall()[0][0]
if local_cache_size == used_pages or nretries == 0:
break
nretries = nretries - 1
time.sleep(1)
assert local_cache_size == used_pages