Skip to content

PG-PG: Add feature to clean up older raw table data, behind FF - #4624

Open
Amogh-Bharadwaj wants to merge 9 commits into
mainfrom
pg-pg-raw-table-cleanup
Open

PG-PG: Add feature to clean up older raw table data, behind FF#4624
Amogh-Bharadwaj wants to merge 9 commits into
mainfrom
pg-pg-raw-table-cleanup

Conversation

@Amogh-Bharadwaj

Copy link
Copy Markdown
Contributor

Why

The PeerDB raw table grows large over time and has been seen to take up a lot of storage in the target Postgres peer. We want to provide an inbuilt feature to users to ensure raw table stays at a small size

This is going to be behind a feature flag default OFF for now so that upon rollout, the first occurrence of cleanup will not stall normalize due to large amount of raw table batches.

What

  • Introduces a new Postgres dynconf target
  • Introduces a new dynamic conf setting with above PG target for cleanup threshold
  • In PG to PG normalize, introduces a call to clean up raw table data based on the normalize batch ID and above threshold setting
  • Adds an E2E test for above functionality

@Amogh-Bharadwaj
Amogh-Bharadwaj requested review from a team as code owners July 27, 2026 13:47
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
3177 2 3175 393
View the top 2 failed test(s) by shortest run time
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuitePG
Stack Traces | 0.01s run time
=== RUN   TestPeerFlowE2ETestSuitePG
=== PAUSE TestPeerFlowE2ETestSuitePG
=== CONT  TestPeerFlowE2ETestSuitePG
--- FAIL: TestPeerFlowE2ETestSuitePG (0.01s)
2026/07/28 09:27:42 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/28 09:27:42 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
github.com/PeerDB-io/peerdb/flow/e2e::TestPeerFlowE2ETestSuitePG/Test_Raw_Batch_Cleanup_PG
Stack Traces | 74.2s run time
=== RUN   TestPeerFlowE2ETestSuitePG/Test_Raw_Batch_Cleanup_PG
=== PAUSE TestPeerFlowE2ETestSuitePG/Test_Raw_Batch_Cleanup_PG
=== CONT  TestPeerFlowE2ETestSuitePG/Test_Raw_Batch_Cleanup_PG
    postgres_test.go:485: WaitFor normalize batch 1 2026-07-28 09:26:31.429656488 +0000 UTC m=+318.736754582
    postgres_test.go:485: WaitFor normalize batch 2 2026-07-28 09:26:32.434447279 +0000 UTC m=+319.741545393
    postgres_test.go:485: WaitFor normalize batch 3 2026-07-28 09:26:33.437531139 +0000 UTC m=+320.744629243
2026/07/28 09:26:33 INFO Executing and processing query x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart query="SELECT id,name,created_at FROM e2e_test_bq_fmb5zdj3_20260728092512.\"test_inheritance_dynconf\" ORDER BY id"
2026/07/28 09:26:33 INFO Executing and processing query stream x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart query="SELECT id,name,created_at FROM e2e_test_bq_fmb5zdj3_20260728092512.\"test_inheritance_dynconf\" ORDER BY id"
2026/07/28 09:26:33 INFO [pg_query_executor] declared cursor x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart cursorQuery="DECLARE peerdb_cursor_2569146197655160094 CURSOR FOR SELECT id,name,created_at FROM e2e_test_bq_fmb5zdj3_20260728092512.\"test_inheritance_dynconf\" ORDER BY id" args=[]
2026/07/28 09:26:33 INFO [pg_query_executor] fetching rows start x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart query="SELECT id,name,created_at FROM e2e_test_bq_fmb5zdj3_20260728092512.\"test_inheritance_dynconf\" ORDER BY id" channelLen=0
2026/07/28 09:26:33 INFO [pg_query_executor] fetching from cursor x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart cursor=peerdb_cursor_2569146197655160094
2026/07/28 09:26:33 INFO processed row stream x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart cursor=peerdb_cursor_2569146197655160094 records=8 bytes=168 channelLen=7
2026/07/28 09:26:33 INFO [pg_query_executor] fetched rows x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart query="SELECT id,name,created_at FROM e2e_test_bq_fmb5zdj3_20260728092512.\"test_inheritance_dynconf\" ORDER BY id" rows=8 bytes=168 channelLen=7
2026/07/28 09:26:33 INFO [pg_query_executor] fetching from cursor x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart cursor=peerdb_cursor_2569146197655160094
2026/07/28 09:26:33 INFO processed row stream x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart cursor=peerdb_cursor_2569146197655160094 records=0 bytes=0 channelLen=0
2026/07/28 09:26:33 INFO [pg_query_executor] fetched rows x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart query="SELECT id,name,created_at FROM e2e_test_bq_fmb5zdj3_20260728092512.\"test_inheritance_dynconf\" ORDER BY id" rows=0 bytes=0 channelLen=0
2026/07/28 09:26:33 INFO [pg_query_executor] committing transaction x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart
2026/07/28 09:26:33 INFO [pg_query_executor] committed transaction for query x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} partitionId=testpart query="SELECT id,name,created_at FROM e2e_test_bq_fmb5zdj3_20260728092512.\"test_inheritance_dynconf\" ORDER BY id" rows=8 bytes=168 channelLen=0
    postgres_test.go:485: WaitFor normalize batch 4 2026-07-28 09:26:34.440987666 +0000 UTC m=+321.748085770
2026/07/28 09:26:34 INFO fetched schema x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} table=e2e_test_mychclg_locm56l9.test_simple_schema_changes
    postgres_test.go:485: WaitFor normalize batch 5 2026-07-28 09:26:35.444318822 +0000 UTC m=+322.751416907
    postgres_test.go:497: WaitFor raw table cleanup 2026-07-28 09:26:36.445570381 +0000 UTC m=+323.752668485
    postgres_test.go:502: raw table row count: 10
2026/07/28 09:26:36 INFO fetched schema x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} table=e2e_test_mychclg_locm56l9.test_simple_schema_changes
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
2026/07/28 09:26:38 INFO fetched schema x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} table=e2e_test_mychclg_locm56l9.test_simple_schema_changes
    postgres_test.go:502: raw table row count: 10
2026/07/28 09:26:39 INFO fetched schema x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN} table=e2e_test_mychclg_locm56l9.test_simple_schema_changes
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
2026/07/28 09:26:58 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
2026/07/28 09:27:04 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/28 09:27:04 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
2026/07/28 09:27:11 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/28 09:27:11 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
    postgres_test.go:502: raw table row count: 10
2026/07/28 09:27:12 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
2026/07/28 09:27:14 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
2026/07/28 09:27:18 INFO Received AWS credentials from peer for connector: ci x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
2026/07/28 09:27:18 INFO Received AWS credentials from peer for connector: clickhouse x-peerdb-additional-metadata={Operation:FLOW_OPERATION_UNKNOWN}
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:502: raw table row count: 10
    postgres_test.go:497: UNEXPECTED TIMEOUT raw table cleanup 2026-07-28 09:27:36.506605799 +0000 UTC m=+383.813703883
    postgres.go:92: begin tearing down postgres schema pg_l1iqeur7
--- FAIL: TestPeerFlowE2ETestSuitePG/Test_Raw_Batch_Cleanup_PG (74.23s)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: The new Test_Raw_Batch_Cleanup_PG fails deterministically and identically (expected 6 rows, got 10) across all three matrix legs, meaning the PR's raw-table cleanup feature isn't pruning old batches — a real bug, not flakiness.
Confidence: 0.92

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@Amogh-Bharadwaj
Amogh-Bharadwaj force-pushed the pg-pg-raw-table-cleanup branch from 44dbd64 to 0bcfad5 Compare July 28, 2026 08:29
@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: The newly-added Test_Raw_Batch_Cleanup_PG (introduced by this PR, absent on main) times out with the raw-table row count frozen at 10 for the entire 60s wait on two of three matrix jobs, indicating the PR's raw-batch cleanup never runs rather than an environmental or timing flake.
Confidence: 0.85

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@claude

claude Bot commented Jul 28, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: Test_Raw_Batch_Cleanup_PG fails deterministically across all three matrix jobs with the raw table row count frozen at 10 until timeout, indicating the raw-table-cleanup feature this PR adds does not work; the accompanying BigQuery 503 and pg_dump "signal: killed" failures are isolated flakes that only affect single legs.
Confidence: 0.92

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: The new test Test_Raw_Batch_Cleanup_PG added by PR #4624 fails deterministically on all three PG matrix jobs with the raw table row count stuck at 10 for the full ~72s poll window, indicating the PR's raw-table cleanup logic never runs rather than any timing, race, or network flakiness.
Confidence: 0.95

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: Real bug: the PR's own new test Test_Raw_Batch_Cleanup_PG fails identically on all three matrix jobs (pg16/pg17/pg18) because raw-table cleanup never runs — the row count stays pinned at 10 until the 60s wait times out.
Confidence: 0.93

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: The PR's own new test Test_Raw_Batch_Cleanup_PG fails deterministically on all three Postgres matrix jobs with the raw table row count frozen at 10 until the WaitFor deadline, indicating the raw-table cleanup added by this PR never runs rather than an intermittent timing issue.
Confidence: 0.93

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

@github-actions

Copy link
Copy Markdown
Contributor

❌ Test Failure

Analysis: The PR's own new test Test_Raw_Batch_Cleanup_PG fails deterministically on both matrix legs, timing out after 60s with the raw table row count frozen at exactly 10 and never decreasing, indicating the PG→PG raw-table cleanup feature the PR implements is not deleting normalized batches at all.
Confidence: 0.94

⚠️ This appears to be a real bug - manual intervention needed

View workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants