Repository navigation
Back off the MaterializedPostgreSQL consumer after an exception - #127678
alexey-milovidov merged 8 commits into
Conversation
When `MaterializedPostgreSQLConsumer::consume` threw (for example, `syncTables` failed to flush a buffered table because a materialized view on the nested table throws), `PostgreSQLReplicationHandler::consumerFunc` rescheduled the consumer task immediately, ignoring `materialized_postgresql_backoff_min_ms`. The task then ran back-to-back on the pool threads, re-acquiring its `exec_mutex` right away, and `BackgroundSchedulePoolTaskInfo::deactivate` (used by `DETACH TABLE`, `ATTACH TABLE` and shutdown) could starve on that mutex for minutes. This made `test_postgresql_replica_database_engine/test_3.py::test_detach_table_with_pending_buffer` flaky: `DETACH TABLE ... PERMANENTLY` hung for 364 s under ASan. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110493&sha=ca77771a0dba59ede9b97d7b289482f6e8aad138&name_0=PR&name_1=Integration%20tests%20(amd_asan_ubsan%2C%20flaky) #110493 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [6b49d95] Summary: ✅
AI ReviewSummaryPR #127678 routes exceptions escaping Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
|
🕵 Merged the latest |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 13 s compile time in total, 7 of them have a recent master baseline. |
|
🕵 Merged the latest |
|
🕵 Merged the latest |
|
🕵 CI status of commit 44a4ccc: all remaining failures are unrelated to this PR (it only adds a backoff in
|
|
🕵 Merged the latest |
|
🕵 Merged The remaining red check is |
…with_pending_buffer` The test already makes `syncTables` fail on every retry. Use a fixed backoff of 1000 ms and require that six push failures take at least 1.5 s. Without the fix in `PostgreSQLReplicationHandler::consumerFunc`, the consumer retried back-to-back and the failures appeared within 0.5 s. With the fix, the test passes. The materialized view now gets a unique name, so a rerun of the test cannot match log lines from an earlier run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=127678&sha=9c5723ce2c0ab6ef009c97bf3f65e4c1e487d85f&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20s3%20storage%2C%20DBReplicated%2C%20parallel%2C%202%2F2%29 ( The |
|
The fix is already in progress: #126995 (mine, open). @ PedroTadim merged This run has the same cause as the one I described in #125952 (comment). The server log of this job (server time):
pid 122753 inherited the pseudo-terminal master ( |
|
🕵 Thanks @groeneai. Merged the latest |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Trivial. LGTM.
When
MaterializedPostgreSQLConsumer::consumethrows (for example,syncTablescannot flush a buffered table because a materialized view on the nested table throws),PostgreSQLReplicationHandler::consumerFuncrescheduled the consumer task immediately and ignoredmaterialized_postgresql_backoff_min_ms. The task then ran back-to-back on the pool threads and re-acquired itsexec_mutexright away.BackgroundSchedulePoolTaskInfo::deactivate, whichDETACH TABLE,ATTACH TABLEand shutdown call, could starve on that mutex for minutes. The consumer now backs off after an exception, the same wayconsumealready does for the errors it handles itself.This is why
test_postgresql_replica_database_engine/test_3.py::test_detach_table_with_pending_bufferis flaky:DETACH TABLE test_database.test_detach_stuck PERMANENTLYtook 364 s under ASan, and the log showed thousands ofScheduling replication thread: nowretries meanwhile. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110493&sha=ca77771a0dba59ede9b97d7b289482f6e8aad138&name_0=PR&name_1=Integration%20tests%20(amd_asan_ubsan%2C%20flaky). The same hang was seen on #120273, which only touched tests.The test
test_detach_table_with_pending_buffernow uses a fixed backoff of 1000 ms and requires repeated sync failures to take at least 1.5 s. Locally, without the fix the failures arrived within 0.5 s and the test failed; with the fix it passes.Related: #110493
Related: #120273
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
MaterializedPostgreSQLno longer retries a failing synchronization in a tight loop, which could makeDETACH TABLEhang for minutes.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127678]
Version info
26.11.1.980-master(included in26.11and later)