Hold list of all layers in memory.

Previously, the LayerMap was only used as a cache to hold the snapshot
layers that were loaded into memory. As a result, we often had to scan
the filesystem to get list of all the other snapshot files that exist on
disk, but hadn't been loaded into memory yet. That was very slow, consuming
huge amounts of CPU and causing timeouts in any non-trivial tests. Refactor
so that on startup, we scan the directory once and keep the list of
layers in memory.
This commit is contained in:
Heikki Linnakangas
2021-08-02 14:59:26 +03:00
parent aad4d1da85
commit be1386a555
10 changed files with 745 additions and 704 deletions

View File

@@ -32,6 +32,11 @@ def test_snapfiles_gc(zenith_cli, pageserver, postgres, pg_bin):
# Create a test table
cur.execute("CREATE TABLE foo(x integer)")
print("Inserting two more rows and running GC")
cur.execute("select relfilenode from pg_class where oid = 'foo'::regclass");
row = cur.fetchone();
print("relfilenode is {}", row[0]);
# Run GC, to clear out any garbage left behind in the catalogs by
# the CREATE TABLE command. We want to have a clean slate with no garbage
# before running the actual tests below, otherwise the counts won't match