cpp-cdc-subscription-state-persistence
Done. The solution is written to ~/solution-cpp-cdc-subscription-state-persistence.md.
Environment note: No RT-GAP-037 / RethinkDB fork source tree exists in ~ (searched for subscription*, publication_set_state, the config-change types, etc. — nothing). The document therefore reconstructs the fix from the exact APIs and the stated precedent given in the problem, and is written to be dropped into the fork with path/type-name adjustments.
What the bug is: CREATING is written to the durable Raft subscription_config_t at create and never updated — subscription_status reads from the durable config, so the pump streaming rows has no effect on the reported state. It reports creating forever.
The fix (mirrors the publication second-commit precedent):
1. Add table_config_and_shards_change_t::subscription_set_state_t — the analog of publication_set_state_t — with a ctor, classifier tag (RDB_IMPL_SERIALIZABLE_3), and an apply_change that find-by-id → set-state → mark raft dirty against config.subscriptions, tolerant of an unknown id and idempotent on restarts.
2. The pump (which already holds table_meta_client_) calls set_config(subscription_set_state_t(table, id, STREAMING)) the moment its changefeed opens.
Verification: the canonical E2E assertion — insert a signed row into the source table, then assert subscription_status == streaming within 5s of row delivery, plus a restart/durability check and a negative check that the unpatched build still reports creating.
The document includes section-by-section root cause, the exact code for the artifact and the pump placement, a compatibility/idempotency check, and a patch summary table.
# Evidence - Problem class: cpp-cdc-subscription-state-persistence - Model: openrouter/deepseek/deepseek-v4-flash-0731 - Solved: 2026-08-24T07:59:52.767Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "RethinkDB fork RT-GAP-037: subscription_status reported creating forever because the CDC pump streamed rows but never persisted subscription_state_t transitions \u2014 the state lives in the Raft table config (subscription_config_t), recorded CREATING at create and never updated. Fix pattern: add table_config_and_shards_change_t::subscription_set_state_t mirroring the existing publication_set_state_t (struct + ctor + apply_change find-by-id set-state + RDB_IMPL_SERIALIZABLE_3), then have the pump (which already holds table_meta_client_) apply set_config with STREAMING once the changefeed opens. Precedent was the identical publication bug fixed by a second Raft commit. E2E assertion: subscription_status state == streaming within 5s of row delivery.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "cpp-cdc-subscription-state-persistence", "provider": "openrouter", "solved_at": "2026-08-24T07:59:52.767Z", "version": ""}Done. The solution is written to ~/solution-cpp-cdc-subscription-state-persistence.md.
Environment note: No RT-GAP-037 / RethinkDB fork source tree exists in ~ (searched for subscription*, publication_set_state, the config-change types, etc. — nothing). The document therefore reconstructs the fix from the exact APIs and the stated precedent given in the problem, and is written to be dropped into the fork with path/type-name adjustments.
What the bug is: CREATING is written to the durable Raft subscription_config_t at create and never updated — subscription_status reads from the durable config, so the pump streaming rows has no effect on the reported state. It reports creating forever.
The fix (mirrors the publication second-commit precedent):
1. Add table_config_and_shards_change_t::subscription_set_state_t — the analog of publication_set_state_t — with a ctor, classifier tag (RDB_IMPL_SERIALIZABLE_3), and an apply_change that find-by-id → set-state → mark raft dirty against config.subscriptions, tolerant of an unknown id and idempotent on restarts.
2. The pump (which already holds table_meta_client_) calls set_config(subscription_set_state_t(table, id, STREAMING)) the moment its changefeed opens.
Verification: the canonical E2E assertion — insert a signed row into the source table, then assert subscription_status == streaming within 5s of row delivery, plus a restart/durability check and a negative check that the unpatched build still reports creating.
The document includes section-by-section root cause, the exact code for the artifact and the pump placement, a compatibility/idempotency check, and a patch summary table.
# Evidence - Problem class: cpp-cdc-subscription-state-persistence - Model: openrouter/deepseek/deepseek-v4-flash-0731 - Solved: 2026-08-24T07:59:52.767Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "RethinkDB fork RT-GAP-037: subscription_status reported creating forever because the CDC pump streamed rows but never persisted subscription_state_t transitions \u2014 the state lives in the Raft table config (subscription_config_t), recorded CREATING at create and never updated. Fix pattern: add table_config_and_shards_change_t::subscription_set_state_t mirroring the existing publication_set_state_t (struct + ctor + apply_change find-by-id set-state + RDB_IMPL_SERIALIZABLE_3), then have the pump (which already holds table_meta_client_) apply set_config with STREAMING once the changefeed opens. Precedent was the identical publication bug fixed by a second Raft commit. E2E assertion: subscription_status state == streaming within 5s of row delivery.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "cpp-cdc-subscription-state-persistence", "provider": "openrouter", "solved_at": "2026-08-24T07:59:52.767Z", "version": ""}