From 82f9b3121a46f761bba8ed1905304d27546382ec Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Thu, 29 Oct 2026 23:48:19 -0400 Subject: [PATCH] Stop the scratch store's compression policy before the collection health plan test seeds (#6944) The follow-up statement test seeds collection_log chunks that are all older than the one-day compress_after of the table's policy. TimescaleDB's scheduler runs that policy on its own clock, so a run landing between the seed and the plan compressed a chunk, and a compressed chunk is read through its own compressed_ index instead of idx_collection_log_watermark. The test now stops the scratch database's background workers right after the migrations, as the other live tests do, and asserts no chunk is compressed before it reads the plan. The index-name asserts are unchanged. --- .../FleetCollectionHealthRecoveryLiveTests.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Darling/Darling.Tests/FleetCollectionHealthRecoveryLiveTests.cs b/Darling/Darling.Tests/FleetCollectionHealthRecoveryLiveTests.cs index 0da1694df1..425e0f1eaa 100644 --- a/Darling/Darling.Tests/FleetCollectionHealthRecoveryLiveTests.cs +++ b/Darling/Darling.Tests/FleetCollectionHealthRecoveryLiveTests.cs @@ -120,6 +120,15 @@ public async Task TheFollowUpStatement_ReadsThreeRunsPerPair_ThroughAnIndex_Agai using var connection = new NpgsqlConnection(scratch.ConnectionString); await connection.OpenAsync(ct); await PgMigrations.MigrateAsync(connection, ct); + if (scratch.TimescaleEnabled) + { + /* V23 made collection_log a hypertable with a compression policy (compress_after 1 day), and every + seeded chunk is older than that. TimescaleDB's scheduler runs the policy on its own clock, so a run + landing between the seed and the plan compressed a chunk, and a compressed chunk is read through its + own "compressed_server_id__ts_meta_v2_first_col_idx" instead of idx_collection_log_watermark (dev run + 40987085936, #6944). The plan is not the thing under test there, so no policy job runs here. */ + await DarlingMcpTestData.ExecAsync(connection, ct, "SELECT _timescaledb_functions.stop_background_workers()"); + } await DeleteRowsAsync(connection, ct); var bodySucceeded = false; @@ -144,6 +153,12 @@ INSERT INTO collection_log CASE WHEN g % 7 = 0 THEN 'ERROR' ELSE 'SUCCESS' END, NULL, 5, 80, 20 FROM generate_series(1, 6) c, generate_series(1, 2000) g", ServerId, ServerName, newest); await DarlingMcpTestData.ExecAsync(connection, ct, "ANALYZE collection_log"); + if (scratch.TimescaleEnabled) + { + await using var compressed = new NpgsqlCommand( + "SELECT count(*) FROM timescaledb_information.chunks WHERE hypertable_name = 'collection_log' AND is_compressed", connection); + Assert.Equal(0L, (long)(await compressed.ExecuteScalarAsync(ct))!); + } var windowStart = DarlingMcpTestData.Naive(DateTime.UtcNow.AddDays(-7)); await using var postgres = NpgsqlDataSource.Create(scratch.ConnectionString);