Skip to content

feat(plugin-backfill): async query submission with concurrency and polling#98

Merged
KeKs0r merged 5 commits intomainfrom
marc/async-query-backfill
Mar 28, 2026
Merged

feat(plugin-backfill): async query submission with concurrency and polling#98
KeKs0r merged 5 commits intomainfrom
marc/async-query-backfill

Conversation

@KeKs0r
Copy link
Copy Markdown
Contributor

@KeKs0r KeKs0r commented Mar 28, 2026

Summary

  • Replace sequential backfill execution with async query submission via ClickHouse's wait_end_of_query: 0 fire-and-forget mode
  • Add submit() and queryStatus() to @chkit/clickhouse's ClickHouseExecutor for async query lifecycle management
  • New executeBackfill() orchestrator in @chkit/plugin-backfill using p-map for configurable concurrency and server-side polling via system.processes/system.query_log
  • Remove old synchronous executor, runtime, simulation flags, compatibility tokens, and event logging (~1,060 lines deleted, ~810 added)
  • Update docs and E2E tests for new --concurrency, --poll-interval, and --replay-failed flags

Test plan

  • 102 unit tests pass (plugin-backfill)
  • Typecheck passes across all packages
  • Docs site builds successfully
  • E2E tests against live ClickHouse (CI)

🤖 Generated with Claude Code

KeKs0r and others added 4 commits March 28, 2026 17:18
…ion and polling

Switch backfill execution from synchronous per-chunk queries to async
query submission via ClickHouse's fire-and-forget mode with server-side
polling through system.processes and system.query_log. Adds configurable
concurrency (--concurrency) and poll interval (--poll-interval) flags.
Removes the old sequential executor, runtime orchestration, simulation
flags, compatibility tokens, and event logging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rance, and replay-failed

- Add syncProgress() to reconcile local checkpoint state with ClickHouse
  system.processes/query_log, recovering from client crashes mid-backfill
- Add afterTime filter to queryStatus() to ignore stale query_log entries
  when resubmitting with deterministic query IDs
- Add maxPollErrors option for transient network error tolerance during polling
- Move replayFailed logic into executeBackfill for correct ordering (sync first,
  then reset confirmed-failed chunks)
- Make plugin.ts enforce explicit resume flow: run command rejects existing runs
  instead of silently continuing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…test timeouts

Return exit code 0 with informational message when resuming an already-completed
backfill instead of throwing an error. Increase E2E test timeouts to 120s for
async query polling reliability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…llReplicas

queryStatus and syncProgress queried system.processes and system.query_log
on a single node, but submit() could route the INSERT to a different replica.
On multi-replica deployments, the poll loop would never find the query,
causing backfill runs to hang indefinitely.

Use clusterAllReplicas('parallel_replicas', ...) with skip_unavailable_shards=1
to fan out across all nodes. Add is_initial_query=1 filter to avoid matching
distributed sub-query log entries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@KeKs0r KeKs0r force-pushed the marc/async-query-backfill branch from 67e8f8a to 419d183 Compare March 28, 2026 17:13
@KeKs0r KeKs0r merged commit cb09aaa into main Mar 28, 2026
2 checks passed
@KeKs0r KeKs0r deleted the marc/async-query-backfill branch March 28, 2026 17:21
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.

1 participant