@chkit/plugin-backfill 0.1.0-beta.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +130 -0
- package/dist/args.d.ts +17 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +11 -0
- package/dist/args.js.map +1 -1
- package/dist/async-backfill.d.ts +64 -0
- package/dist/async-backfill.d.ts.map +1 -0
- package/dist/async-backfill.js +251 -0
- package/dist/async-backfill.js.map +1 -0
- package/dist/check.d.ts +9 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +79 -0
- package/dist/check.js.map +1 -0
- package/dist/chunking/analyze.d.ts +8 -0
- package/dist/chunking/analyze.d.ts.map +1 -0
- package/dist/chunking/analyze.js +8 -0
- package/dist/chunking/analyze.js.map +1 -0
- package/dist/chunking/boundary-codec.d.ts +4 -0
- package/dist/chunking/boundary-codec.d.ts.map +1 -0
- package/dist/chunking/boundary-codec.js +79 -0
- package/dist/chunking/boundary-codec.js.map +1 -0
- package/dist/chunking/build.d.ts +11 -0
- package/dist/chunking/build.d.ts.map +1 -0
- package/dist/chunking/build.js +51 -0
- package/dist/chunking/build.js.map +1 -0
- package/dist/chunking/e2e/constants.d.ts +2 -0
- package/dist/chunking/e2e/constants.d.ts.map +1 -0
- package/dist/chunking/e2e/constants.js +2 -0
- package/dist/chunking/e2e/constants.js.map +1 -0
- package/dist/chunking/e2e/seed-datasets.script.d.ts +20 -0
- package/dist/chunking/e2e/seed-datasets.script.d.ts.map +1 -0
- package/dist/chunking/e2e/seed-datasets.script.js +134 -0
- package/dist/chunking/e2e/seed-datasets.script.js.map +1 -0
- package/dist/chunking/introspect.d.ts +40 -0
- package/dist/chunking/introspect.d.ts.map +1 -0
- package/dist/chunking/introspect.js +187 -0
- package/dist/chunking/introspect.js.map +1 -0
- package/dist/chunking/partition-slices.d.ts +14 -0
- package/dist/chunking/partition-slices.d.ts.map +1 -0
- package/dist/chunking/partition-slices.js +111 -0
- package/dist/chunking/partition-slices.js.map +1 -0
- package/dist/chunking/planner.d.ts +3 -0
- package/dist/chunking/planner.d.ts.map +1 -0
- package/dist/chunking/planner.js +343 -0
- package/dist/chunking/planner.js.map +1 -0
- package/dist/chunking/services/distribution-source.d.ts +11 -0
- package/dist/chunking/services/distribution-source.d.ts.map +1 -0
- package/dist/chunking/services/distribution-source.js +60 -0
- package/dist/chunking/services/distribution-source.js.map +1 -0
- package/dist/chunking/services/metadata-source.d.ts +4 -0
- package/dist/chunking/services/metadata-source.d.ts.map +1 -0
- package/dist/chunking/services/metadata-source.js +138 -0
- package/dist/chunking/services/metadata-source.js.map +1 -0
- package/dist/chunking/services/row-probe.d.ts +12 -0
- package/dist/chunking/services/row-probe.d.ts.map +1 -0
- package/dist/chunking/services/row-probe.js +49 -0
- package/dist/chunking/services/row-probe.js.map +1 -0
- package/dist/chunking/splitter.d.ts +20 -0
- package/dist/chunking/splitter.d.ts.map +1 -0
- package/dist/chunking/splitter.js +76 -0
- package/dist/chunking/splitter.js.map +1 -0
- package/dist/chunking/sql.d.ts +18 -0
- package/dist/chunking/sql.d.ts.map +1 -0
- package/dist/chunking/sql.js +304 -0
- package/dist/chunking/sql.js.map +1 -0
- package/dist/chunking/strategies/equal-width-split.d.ts +3 -0
- package/dist/chunking/strategies/equal-width-split.d.ts.map +1 -0
- package/dist/chunking/strategies/equal-width-split.js +46 -0
- package/dist/chunking/strategies/equal-width-split.js.map +1 -0
- package/dist/chunking/strategies/group-by-key-split.d.ts +3 -0
- package/dist/chunking/strategies/group-by-key-split.d.ts.map +1 -0
- package/dist/chunking/strategies/group-by-key-split.js +54 -0
- package/dist/chunking/strategies/group-by-key-split.js.map +1 -0
- package/dist/chunking/strategies/metadata-single-chunk.d.ts +3 -0
- package/dist/chunking/strategies/metadata-single-chunk.d.ts.map +1 -0
- package/dist/chunking/strategies/metadata-single-chunk.js +5 -0
- package/dist/chunking/strategies/metadata-single-chunk.js.map +1 -0
- package/dist/chunking/strategies/quantile-range-split.d.ts +5 -0
- package/dist/chunking/strategies/quantile-range-split.d.ts.map +1 -0
- package/dist/chunking/strategies/quantile-range-split.js +132 -0
- package/dist/chunking/strategies/quantile-range-split.js.map +1 -0
- package/dist/chunking/strategies/refinement.d.ts +3 -0
- package/dist/chunking/strategies/refinement.d.ts.map +1 -0
- package/dist/chunking/strategies/refinement.js +61 -0
- package/dist/chunking/strategies/refinement.js.map +1 -0
- package/dist/chunking/strategies/string-prefix-split.d.ts +4 -0
- package/dist/chunking/strategies/string-prefix-split.d.ts.map +1 -0
- package/dist/chunking/strategies/string-prefix-split.js +73 -0
- package/dist/chunking/strategies/string-prefix-split.js.map +1 -0
- package/dist/chunking/strategies/temporal-bucket-split.d.ts +3 -0
- package/dist/chunking/strategies/temporal-bucket-split.d.ts.map +1 -0
- package/dist/chunking/strategies/temporal-bucket-split.js +67 -0
- package/dist/chunking/strategies/temporal-bucket-split.js.map +1 -0
- package/dist/chunking/strategy-policy.d.ts +3 -0
- package/dist/chunking/strategy-policy.d.ts.map +1 -0
- package/dist/chunking/strategy-policy.js +4 -0
- package/dist/chunking/strategy-policy.js.map +1 -0
- package/dist/chunking/types.d.ts +137 -0
- package/dist/chunking/types.d.ts.map +1 -0
- package/dist/chunking/types.js +2 -0
- package/dist/chunking/types.js.map +1 -0
- package/dist/chunking/utils/binary-string.d.ts +8 -0
- package/dist/chunking/utils/binary-string.d.ts.map +1 -0
- package/dist/chunking/utils/binary-string.js +52 -0
- package/dist/chunking/utils/binary-string.js.map +1 -0
- package/dist/chunking/utils/ids.d.ts +4 -0
- package/dist/chunking/utils/ids.d.ts.map +1 -0
- package/dist/chunking/utils/ids.js +11 -0
- package/dist/chunking/utils/ids.js.map +1 -0
- package/dist/chunking/utils/ranges.d.ts +5 -0
- package/dist/chunking/utils/ranges.d.ts.map +1 -0
- package/dist/chunking/utils/ranges.js +19 -0
- package/dist/chunking/utils/ranges.js.map +1 -0
- package/dist/detect.d.ts +8 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +72 -0
- package/dist/detect.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/logging.d.ts +12 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +61 -0
- package/dist/logging.js.map +1 -0
- package/dist/options.d.ts +140 -4
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +145 -111
- package/dist/options.js.map +1 -1
- package/dist/payload.d.ts +7 -17
- package/dist/payload.d.ts.map +1 -1
- package/dist/payload.js +7 -19
- package/dist/payload.js.map +1 -1
- package/dist/planner.d.ts +10 -8
- package/dist/planner.d.ts.map +1 -1
- package/dist/planner.js +76 -97
- package/dist/planner.js.map +1 -1
- package/dist/plugin.d.ts +4 -3
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +351 -201
- package/dist/plugin.js.map +1 -1
- package/dist/queries.d.ts +21 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +113 -0
- package/dist/queries.js.map +1 -0
- package/dist/runtime.d.ts +14 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +162 -83
- package/dist/runtime.js.map +1 -1
- package/dist/sdk.d.ts +12 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +9 -0
- package/dist/sdk.js.map +1 -0
- package/dist/state.d.ts +16 -28
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +73 -127
- package/dist/state.js.map +1 -1
- package/dist/table-config.d.ts +9 -0
- package/dist/table-config.d.ts.map +1 -0
- package/dist/table-config.js +2 -0
- package/dist/table-config.js.map +1 -0
- package/dist/types.d.ts +48 -118
- package/dist/types.d.ts.map +1 -1
- package/package.json +25 -2
package/README.md
CHANGED
|
@@ -35,6 +35,136 @@ export default defineConfig({
|
|
|
35
35
|
|
|
36
36
|
See the [chkit documentation](https://chkit.obsessiondb.com).
|
|
37
37
|
|
|
38
|
+
## SDK
|
|
39
|
+
|
|
40
|
+
The package root is limited to the plugin registration API. Everything used by the CLI itself — the chunk planner, SQL builders, async executor, logging — is also exported from the `@chkit/plugin-backfill/sdk` subpath so you can build your own backfill scripts without going through the CLI.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import {
|
|
44
|
+
generateChunkPlan,
|
|
45
|
+
buildChunkExecutionSql,
|
|
46
|
+
executeBackfill,
|
|
47
|
+
getBackfillLogger,
|
|
48
|
+
type ChunkPlan,
|
|
49
|
+
type PlannerQuery,
|
|
50
|
+
} from '@chkit/plugin-backfill/sdk'
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The pipeline has three stages, and you can use any subset:
|
|
54
|
+
|
|
55
|
+
1. **Plan** — `generateChunkPlan(...)` introspects a table and returns a `ChunkPlan` describing how to partition the work into roughly equal-sized chunks.
|
|
56
|
+
2. **Build SQL** — `buildChunkExecutionSql(...)` turns a single `Chunk` into an `INSERT … SELECT` statement.
|
|
57
|
+
3. **Execute** — `executeBackfill(...)` submits chunks against a real `ClickHouseExecutor` with deterministic query IDs, polling, and resume support.
|
|
58
|
+
|
|
59
|
+
### Plan a backfill
|
|
60
|
+
|
|
61
|
+
`generateChunkPlan` is decoupled from any ClickHouse client. You pass in a `query` function with the `PlannerQuery` shape and the planner uses it for every introspection / probe / split query. This makes the planner trivial to instrument or run against alternative clients.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { createClient } from '@clickhouse/client'
|
|
65
|
+
import { generateChunkPlan, type PlannerQuery } from '@chkit/plugin-backfill/sdk'
|
|
66
|
+
|
|
67
|
+
const client = createClient({ url: process.env.CLICKHOUSE_URL })
|
|
68
|
+
|
|
69
|
+
const query: PlannerQuery = async (sql, settings) => {
|
|
70
|
+
const result = await client.query({
|
|
71
|
+
query: sql,
|
|
72
|
+
format: 'JSONEachRow',
|
|
73
|
+
clickhouse_settings: settings as Record<string, string | number | boolean>,
|
|
74
|
+
})
|
|
75
|
+
return result.json()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const plan = await generateChunkPlan({
|
|
79
|
+
database: 'analytics',
|
|
80
|
+
table: 'events',
|
|
81
|
+
from: '2025-01-01T00:00:00Z',
|
|
82
|
+
to: '2025-02-01T00:00:00Z',
|
|
83
|
+
targetChunkBytes: 1_000_000_000, // ~1 GiB per chunk
|
|
84
|
+
query,
|
|
85
|
+
// 'count' is exact but slower; 'explain-estimate' is faster but approximate
|
|
86
|
+
rowProbeStrategy: 'count',
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
console.log(`${plan.chunks.length} chunks, ${plan.totalRows.toLocaleString()} rows`)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Execute chunks against a target
|
|
93
|
+
|
|
94
|
+
`buildChunkExecutionSql` produces the per-chunk `INSERT … SELECT` and `executeBackfill` runs them with concurrency, polling, and progress callbacks. Persist the `progress` argument anywhere you like to support resume.
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { createClickHouseExecutor } from '@chkit/clickhouse'
|
|
98
|
+
import {
|
|
99
|
+
buildChunkExecutionSql,
|
|
100
|
+
executeBackfill,
|
|
101
|
+
type BackfillProgress,
|
|
102
|
+
} from '@chkit/plugin-backfill/sdk'
|
|
103
|
+
|
|
104
|
+
const executor = createClickHouseExecutor({
|
|
105
|
+
url: process.env.CLICKHOUSE_URL!,
|
|
106
|
+
username: 'default',
|
|
107
|
+
password: process.env.CLICKHOUSE_PASSWORD!,
|
|
108
|
+
database: 'analytics',
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
const chunksById = new Map(plan.chunks.map((chunk) => [chunk.id, chunk]))
|
|
112
|
+
let saved: BackfillProgress | undefined // load from disk for resume
|
|
113
|
+
|
|
114
|
+
const result = await executeBackfill({
|
|
115
|
+
executor,
|
|
116
|
+
planId: plan.planId,
|
|
117
|
+
chunks: plan.chunks,
|
|
118
|
+
buildQuery: ({ id }) =>
|
|
119
|
+
buildChunkExecutionSql({
|
|
120
|
+
planId: plan.planId,
|
|
121
|
+
chunk: chunksById.get(id)!,
|
|
122
|
+
target: 'analytics.events_backfill',
|
|
123
|
+
table: plan.table,
|
|
124
|
+
}),
|
|
125
|
+
concurrency: 4,
|
|
126
|
+
pollIntervalMs: 5_000,
|
|
127
|
+
resumeFrom: saved,
|
|
128
|
+
onProgress: async (progress) => {
|
|
129
|
+
saved = progress
|
|
130
|
+
// persist to disk / state store
|
|
131
|
+
},
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
console.log(`done=${result.completed} failed=${result.failed}`)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Plan persistence
|
|
138
|
+
|
|
139
|
+
Plans contain string boundaries that may include non-UTF-8 bytes (the planner uses `latin1`-encoded byte ranges for string sort keys), so JSON-serializing a `ChunkPlan` directly will lose information. Use the codec helpers when you need to round-trip a plan through storage:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import {
|
|
143
|
+
encodeChunkPlanForPersistence,
|
|
144
|
+
decodeChunkPlanFromPersistence,
|
|
145
|
+
} from '@chkit/plugin-backfill/sdk'
|
|
146
|
+
|
|
147
|
+
const json = JSON.stringify(encodeChunkPlanForPersistence(plan))
|
|
148
|
+
// later …
|
|
149
|
+
const plan2 = decodeChunkPlanFromPersistence(JSON.parse(json))
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Logging
|
|
153
|
+
|
|
154
|
+
The planner emits structured logs via [`@logtape/logtape`](https://logtape.org/) under the `['chkit', 'backfill']` category. Configure a sink at process start to see them — slow-query warnings (>5 s) are emitted at `warning` level, planning progress at `info`, and per-strategy decisions at `debug`.
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
import { configureSync, getConsoleSink, getTextFormatter } from '@chkit/plugin-backfill/sdk'
|
|
158
|
+
|
|
159
|
+
configureSync({
|
|
160
|
+
sinks: { console: getConsoleSink({ formatter: getTextFormatter({ timestamp: 'time' }) }) },
|
|
161
|
+
loggers: [{ category: 'chkit', sinks: ['console'], lowestLevel: 'info' }],
|
|
162
|
+
reset: true,
|
|
163
|
+
})
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
To capture every SQL statement the planner runs (with timing, server-side stats, and per-strategy classification), wrap your `query` function instead of relying solely on logging — the wrapper sees the raw SQL and settings on every call and can record query IDs, response headers, and durations alongside the structured logs.
|
|
167
|
+
|
|
38
168
|
## License
|
|
39
169
|
|
|
40
170
|
[MIT](../../LICENSE)
|
package/dist/args.d.ts
CHANGED
|
@@ -20,10 +20,19 @@ export declare const PLAN_FLAGS: readonly [{
|
|
|
20
20
|
readonly type: "string";
|
|
21
21
|
readonly description: "Hours per chunk";
|
|
22
22
|
readonly placeholder: "<hours>";
|
|
23
|
+
}, {
|
|
24
|
+
readonly name: "--time-column";
|
|
25
|
+
readonly type: "string";
|
|
26
|
+
readonly description: "Time column for WHERE clause";
|
|
27
|
+
readonly placeholder: "<column>";
|
|
23
28
|
}, {
|
|
24
29
|
readonly name: "--force-large-window";
|
|
25
30
|
readonly type: "boolean";
|
|
26
31
|
readonly description: "Allow large time windows without confirmation";
|
|
32
|
+
}, {
|
|
33
|
+
readonly name: "--force";
|
|
34
|
+
readonly type: "boolean";
|
|
35
|
+
readonly description: "Delete existing plan and regenerate from scratch";
|
|
27
36
|
}];
|
|
28
37
|
export declare const RUN_FLAGS: readonly [{
|
|
29
38
|
readonly name: "--plan-id";
|
|
@@ -46,6 +55,10 @@ export declare const RUN_FLAGS: readonly [{
|
|
|
46
55
|
readonly name: "--force-compatibility";
|
|
47
56
|
readonly type: "boolean";
|
|
48
57
|
readonly description: "Skip compatibility checks";
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: "--force-environment";
|
|
60
|
+
readonly type: "boolean";
|
|
61
|
+
readonly description: "Skip environment mismatch checks";
|
|
49
62
|
}, {
|
|
50
63
|
readonly name: "--simulate-fail-chunk";
|
|
51
64
|
readonly type: "string";
|
|
@@ -78,6 +91,10 @@ export declare const RESUME_FLAGS: readonly [{
|
|
|
78
91
|
readonly name: "--force-compatibility";
|
|
79
92
|
readonly type: "boolean";
|
|
80
93
|
readonly description: "Skip compatibility checks";
|
|
94
|
+
}, {
|
|
95
|
+
readonly name: "--force-environment";
|
|
96
|
+
readonly type: "boolean";
|
|
97
|
+
readonly description: "Skip environment mismatch checks";
|
|
81
98
|
}];
|
|
82
99
|
export declare const PLAN_ID_FLAGS: readonly [{
|
|
83
100
|
readonly name: "--plan-id";
|
package/dist/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAGvE,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAGvE,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EACjB,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQZ,CAAA;AAEX,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASX,CAAA;AAEX,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;EAOd,CAAA;AAEX,eAAO,MAAM,aAAa;;;;;EAEf,CAAA;AAgCX,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAgChE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,CAgC9D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,CAUpE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,CAKpE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,CAEpE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,CAEpE"}
|
package/dist/args.js
CHANGED
|
@@ -5,7 +5,9 @@ export const PLAN_FLAGS = defineFlags([
|
|
|
5
5
|
{ name: '--from', type: 'string', description: 'Start timestamp', placeholder: '<timestamp>' },
|
|
6
6
|
{ name: '--to', type: 'string', description: 'End timestamp', placeholder: '<timestamp>' },
|
|
7
7
|
{ name: '--chunk-hours', type: 'string', description: 'Hours per chunk', placeholder: '<hours>' },
|
|
8
|
+
{ name: '--time-column', type: 'string', description: 'Time column for WHERE clause', placeholder: '<column>' },
|
|
8
9
|
{ name: '--force-large-window', type: 'boolean', description: 'Allow large time windows without confirmation' },
|
|
10
|
+
{ name: '--force', type: 'boolean', description: 'Delete existing plan and regenerate from scratch' },
|
|
9
11
|
]);
|
|
10
12
|
export const RUN_FLAGS = defineFlags([
|
|
11
13
|
{ name: '--plan-id', type: 'string', description: 'Plan ID to execute', placeholder: '<id>' },
|
|
@@ -13,6 +15,7 @@ export const RUN_FLAGS = defineFlags([
|
|
|
13
15
|
{ name: '--replay-failed', type: 'boolean', description: 'Re-execute failed chunks' },
|
|
14
16
|
{ name: '--force-overlap', type: 'boolean', description: 'Allow overlapping runs' },
|
|
15
17
|
{ name: '--force-compatibility', type: 'boolean', description: 'Skip compatibility checks' },
|
|
18
|
+
{ name: '--force-environment', type: 'boolean', description: 'Skip environment mismatch checks' },
|
|
16
19
|
{ name: '--simulate-fail-chunk', type: 'string', description: 'Simulate failure on chunk', placeholder: '<chunk-id>' },
|
|
17
20
|
{ name: '--simulate-fail-count', type: 'string', description: 'Number of simulated failures', placeholder: '<count>' },
|
|
18
21
|
]);
|
|
@@ -22,6 +25,7 @@ export const RESUME_FLAGS = defineFlags([
|
|
|
22
25
|
{ name: '--replay-failed', type: 'boolean', description: 'Re-execute failed chunks' },
|
|
23
26
|
{ name: '--force-overlap', type: 'boolean', description: 'Allow overlapping runs' },
|
|
24
27
|
{ name: '--force-compatibility', type: 'boolean', description: 'Skip compatibility checks' },
|
|
28
|
+
{ name: '--force-environment', type: 'boolean', description: 'Skip environment mismatch checks' },
|
|
25
29
|
]);
|
|
26
30
|
export const PLAN_ID_FLAGS = defineFlags([
|
|
27
31
|
{ name: '--plan-id', type: 'string', description: 'Plan ID', placeholder: '<id>' },
|
|
@@ -57,7 +61,9 @@ export function parsePlanArgs(flags) {
|
|
|
57
61
|
const from = f['--from'];
|
|
58
62
|
const to = f['--to'];
|
|
59
63
|
const rawChunkHours = f['--chunk-hours'];
|
|
64
|
+
const timeColumn = f['--time-column'];
|
|
60
65
|
const forceLargeWindow = f['--force-large-window'] === true;
|
|
66
|
+
const force = f['--force'] === true;
|
|
61
67
|
let chunkHours;
|
|
62
68
|
if (rawChunkHours !== undefined) {
|
|
63
69
|
const parsed = Number(rawChunkHours);
|
|
@@ -77,7 +83,9 @@ export function parsePlanArgs(flags) {
|
|
|
77
83
|
from: normalizeTimestamp(from, '--from'),
|
|
78
84
|
to: normalizeTimestamp(to, '--to'),
|
|
79
85
|
chunkHours,
|
|
86
|
+
timeColumn: timeColumn?.trim() || undefined,
|
|
80
87
|
forceLargeWindow,
|
|
88
|
+
force,
|
|
81
89
|
};
|
|
82
90
|
}
|
|
83
91
|
export function parseRunArgs(flags) {
|
|
@@ -87,6 +95,7 @@ export function parseRunArgs(flags) {
|
|
|
87
95
|
const replayFailed = f['--replay-failed'] === true;
|
|
88
96
|
const forceOverlap = f['--force-overlap'] === true;
|
|
89
97
|
const forceCompatibility = f['--force-compatibility'] === true;
|
|
98
|
+
const forceEnvironment = f['--force-environment'] === true;
|
|
90
99
|
const simulateFailChunk = f['--simulate-fail-chunk'];
|
|
91
100
|
let simulateFailCount = 1;
|
|
92
101
|
const rawSimulateFailCount = f['--simulate-fail-count'];
|
|
@@ -105,6 +114,7 @@ export function parseRunArgs(flags) {
|
|
|
105
114
|
replayFailed,
|
|
106
115
|
forceOverlap,
|
|
107
116
|
forceCompatibility,
|
|
117
|
+
forceEnvironment,
|
|
108
118
|
simulateFailChunk,
|
|
109
119
|
simulateFailCount,
|
|
110
120
|
};
|
|
@@ -117,6 +127,7 @@ export function parseResumeArgs(flags) {
|
|
|
117
127
|
replayFailed: parsed.replayFailed,
|
|
118
128
|
forceOverlap: parsed.forceOverlap,
|
|
119
129
|
forceCompatibility: parsed.forceCompatibility,
|
|
130
|
+
forceEnvironment: parsed.forceEnvironment,
|
|
120
131
|
};
|
|
121
132
|
}
|
|
122
133
|
export function parseStatusArgs(flags) {
|
package/dist/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAoB,MAAM,aAAa,CAAA;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAUjD,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC;IACpC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+BAA+B,EAAE,WAAW,EAAE,kBAAkB,EAAE;IACnH,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE;IAC9F,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE;IAC1F,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,WAAW,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AM;QAAE,MAAM,IAAI,mBAAmB,CAAC,iCAAiC,CAAC,CAAA;IAE7E,OAAO;QACL,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;QAC/B,UAAU;QACV,YAAY;QACZ,YAAY;QACZ,kBAAkB;QAClB,gBAAgB;QAChB,iBAAiB;QACjB,iBAAiB;KAClB,CAAA;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAkB;IAChD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAA;IAClC,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,CAAA;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAkB;IAChD,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,CAAA;IAC1C,MAAM,MAAM,GAAG,CAAC,CAAC,WAAW,CAAC,CAAA;IAC7B,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,mBAAmB,CAAC,iCAAiC,CAAC,CAAA;IAC7E,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,CAAA;AAC5C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAkB;IAChD,OAAO,eAAe,CAAC,KAAK,CAAC,CAAA;AAC/B,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAkB;IAChD,OAAO,eAAe,CAAC,KAAK,CAAC,CAAA;AAC/B,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ClickHouseExecutor } from '@chkit/clickhouse';
|
|
2
|
+
export interface BackfillOptions {
|
|
3
|
+
/** The executor to submit queries to (target ClickHouse) */
|
|
4
|
+
executor: ClickHouseExecutor;
|
|
5
|
+
/** Plan ID used as a namespace in deterministic query IDs */
|
|
6
|
+
planId: string;
|
|
7
|
+
/** The chunks to process (from buildChunks) */
|
|
8
|
+
chunks: Array<{
|
|
9
|
+
id: string;
|
|
10
|
+
from?: string;
|
|
11
|
+
to?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}>;
|
|
14
|
+
/** Build the SQL for a given chunk. Called once per chunk at submit time. */
|
|
15
|
+
buildQuery: (chunk: {
|
|
16
|
+
id: string;
|
|
17
|
+
from?: string;
|
|
18
|
+
to?: string;
|
|
19
|
+
}) => string;
|
|
20
|
+
/** Max concurrent queries running on the server. Default: 3 */
|
|
21
|
+
concurrency?: number;
|
|
22
|
+
/** Polling interval in ms. Default: 5000 */
|
|
23
|
+
pollIntervalMs?: number;
|
|
24
|
+
/** Max consecutive poll errors before marking a chunk as failed. Default: 10 */
|
|
25
|
+
maxPollErrors?: number;
|
|
26
|
+
/** Called whenever progress changes. Use this to persist state. */
|
|
27
|
+
onProgress?: (progress: BackfillProgress) => void | Promise<void>;
|
|
28
|
+
/** Previously saved progress to resume from. */
|
|
29
|
+
resumeFrom?: BackfillProgress;
|
|
30
|
+
/** When true, reset chunks confirmed failed (both locally and on server) back to pending. */
|
|
31
|
+
replayFailed?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface BackfillChunkState {
|
|
34
|
+
status: 'pending' | 'submitted' | 'running' | 'done' | 'failed';
|
|
35
|
+
queryId?: string;
|
|
36
|
+
submittedAt?: string;
|
|
37
|
+
finishedAt?: string;
|
|
38
|
+
readRows?: number;
|
|
39
|
+
readBytes?: number;
|
|
40
|
+
writtenRows?: number;
|
|
41
|
+
writtenBytes?: number;
|
|
42
|
+
elapsedMs?: number;
|
|
43
|
+
durationMs?: number;
|
|
44
|
+
error?: string;
|
|
45
|
+
}
|
|
46
|
+
export type BackfillProgress = Record<string, BackfillChunkState>;
|
|
47
|
+
export interface BackfillResult {
|
|
48
|
+
total: number;
|
|
49
|
+
completed: number;
|
|
50
|
+
failed: number;
|
|
51
|
+
progress: BackfillProgress;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Reconcile local progress with server-side state.
|
|
55
|
+
*
|
|
56
|
+
* Queries system.processes and system.query_log for all chunk query IDs
|
|
57
|
+
* to discover queries that were submitted but whose status was never
|
|
58
|
+
* persisted locally (e.g. client crash between submit and state write).
|
|
59
|
+
*/
|
|
60
|
+
export declare function syncProgress(executor: ClickHouseExecutor, planId: string, chunks: Array<{
|
|
61
|
+
id: string;
|
|
62
|
+
}>, progress: BackfillProgress): Promise<BackfillProgress>;
|
|
63
|
+
export declare function executeBackfill(options: BackfillOptions): Promise<BackfillResult>;
|
|
64
|
+
//# sourceMappingURL=async-backfill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-backfill.d.ts","sourceRoot":"","sources":["../src/async-backfill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,mBAAmB,CAAA;AAGxE,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAA;IACd,+CAA+C;IAC/C,MAAM,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,CAAA;IACjF,6EAA6E;IAC7E,UAAU,EAAE,CAAC,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAA;IACzE,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4CAA4C;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gB,CAAC,CAoF3B;AA2CD,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAsGvF"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import pMap from 'p-map';
|
|
2
|
+
function sleep(ms) {
|
|
3
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
4
|
+
}
|
|
5
|
+
/** Build the deterministic query ID for a chunk. */
|
|
6
|
+
function chunkQueryId(planId, chunkId) {
|
|
7
|
+
return `backfill-${planId}-${chunkId}`;
|
|
8
|
+
}
|
|
9
|
+
function applyQueryStatus(state, qs) {
|
|
10
|
+
if (qs.status === 'running') {
|
|
11
|
+
const next = {
|
|
12
|
+
...state,
|
|
13
|
+
status: 'running',
|
|
14
|
+
readRows: qs.readRows,
|
|
15
|
+
readBytes: qs.readBytes,
|
|
16
|
+
writtenRows: qs.writtenRows,
|
|
17
|
+
writtenBytes: qs.writtenBytes,
|
|
18
|
+
elapsedMs: qs.elapsedMs,
|
|
19
|
+
};
|
|
20
|
+
const metricsChanged = state.status !== 'running' ||
|
|
21
|
+
state.readRows !== qs.readRows ||
|
|
22
|
+
state.writtenRows !== qs.writtenRows ||
|
|
23
|
+
state.elapsedMs !== qs.elapsedMs;
|
|
24
|
+
return { state: next, changed: metricsChanged };
|
|
25
|
+
}
|
|
26
|
+
if (qs.status === 'finished') {
|
|
27
|
+
return {
|
|
28
|
+
state: {
|
|
29
|
+
...state,
|
|
30
|
+
status: 'done',
|
|
31
|
+
finishedAt: new Date().toISOString(),
|
|
32
|
+
durationMs: qs.durationMs,
|
|
33
|
+
writtenRows: qs.writtenRows,
|
|
34
|
+
writtenBytes: qs.writtenBytes,
|
|
35
|
+
},
|
|
36
|
+
changed: true,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (qs.status === 'failed') {
|
|
40
|
+
return {
|
|
41
|
+
state: {
|
|
42
|
+
...state,
|
|
43
|
+
status: 'failed',
|
|
44
|
+
finishedAt: new Date().toISOString(),
|
|
45
|
+
durationMs: qs.durationMs,
|
|
46
|
+
error: qs.error,
|
|
47
|
+
},
|
|
48
|
+
changed: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// 'unknown' — leave status as-is (query_log may not have flushed yet)
|
|
52
|
+
return { state, changed: false };
|
|
53
|
+
}
|
|
54
|
+
function getChunk(progress, id) {
|
|
55
|
+
const state = progress[id];
|
|
56
|
+
if (!state)
|
|
57
|
+
throw new Error(`No progress entry for chunk ${id}`);
|
|
58
|
+
return state;
|
|
59
|
+
}
|
|
60
|
+
function updateChunk(progress, id, next) {
|
|
61
|
+
return { ...progress, [id]: next };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Reconcile local progress with server-side state.
|
|
65
|
+
*
|
|
66
|
+
* Queries system.processes and system.query_log for all chunk query IDs
|
|
67
|
+
* to discover queries that were submitted but whose status was never
|
|
68
|
+
* persisted locally (e.g. client crash between submit and state write).
|
|
69
|
+
*/
|
|
70
|
+
export async function syncProgress(executor, planId, chunks, progress) {
|
|
71
|
+
const prefix = `backfill-${planId}-`;
|
|
72
|
+
// Collect query IDs for non-terminal chunks that need reconciliation
|
|
73
|
+
const chunkIdsToSync = [];
|
|
74
|
+
for (const chunk of chunks) {
|
|
75
|
+
const state = progress[chunk.id];
|
|
76
|
+
if (!state || state.status === 'done')
|
|
77
|
+
continue;
|
|
78
|
+
chunkIdsToSync.push(chunk.id);
|
|
79
|
+
}
|
|
80
|
+
if (chunkIdsToSync.length === 0)
|
|
81
|
+
return progress;
|
|
82
|
+
// Escape single-quotes in the prefix for safe SQL embedding
|
|
83
|
+
const safePrefix = prefix.replace(/'/g, "''").replace(/%/g, '\\%').replace(/_/g, '\\_');
|
|
84
|
+
const runningRows = await executor.query(`SELECT query_id FROM clusterAllReplicas('cluster', system.processes) WHERE user = currentUser() AND query_id LIKE '${safePrefix}%' SETTINGS skip_unavailable_shards = 1`);
|
|
85
|
+
const runningSet = new Set(runningRows.map((r) => r.query_id));
|
|
86
|
+
const logRows = await executor.query(`SELECT query_id, type, written_rows, written_bytes, query_duration_ms, exception
|
|
87
|
+
FROM clusterAllReplicas('cluster', system.query_log)
|
|
88
|
+
WHERE user = currentUser()
|
|
89
|
+
AND query_id LIKE '${safePrefix}%'
|
|
90
|
+
AND type IN ('QueryFinish', 'ExceptionWhileProcessing')
|
|
91
|
+
AND is_initial_query = 1
|
|
92
|
+
ORDER BY event_time DESC
|
|
93
|
+
SETTINGS skip_unavailable_shards = 1`);
|
|
94
|
+
// Deduplicate: take the latest log entry per query_id (results are ordered by event_time DESC)
|
|
95
|
+
const latestLogByQueryId = new Map();
|
|
96
|
+
for (const row of logRows) {
|
|
97
|
+
if (!latestLogByQueryId.has(row.query_id)) {
|
|
98
|
+
latestLogByQueryId.set(row.query_id, row);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
let updated = { ...progress };
|
|
102
|
+
for (const chunkId of chunkIdsToSync) {
|
|
103
|
+
const queryId = chunkQueryId(planId, chunkId);
|
|
104
|
+
const current = updated[chunkId];
|
|
105
|
+
if (!current)
|
|
106
|
+
continue;
|
|
107
|
+
if (runningSet.has(queryId)) {
|
|
108
|
+
updated = updateChunk(updated, chunkId, { ...current, status: 'running', queryId });
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const logEntry = latestLogByQueryId.get(queryId);
|
|
112
|
+
if (logEntry) {
|
|
113
|
+
if (logEntry.type === 'QueryFinish') {
|
|
114
|
+
updated = updateChunk(updated, chunkId, {
|
|
115
|
+
...current,
|
|
116
|
+
status: 'done',
|
|
117
|
+
queryId,
|
|
118
|
+
finishedAt: new Date().toISOString(),
|
|
119
|
+
writtenRows: Number(logEntry.written_rows),
|
|
120
|
+
writtenBytes: Number(logEntry.written_bytes),
|
|
121
|
+
durationMs: Number(logEntry.query_duration_ms),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
updated = updateChunk(updated, chunkId, {
|
|
126
|
+
...current,
|
|
127
|
+
status: 'failed',
|
|
128
|
+
queryId,
|
|
129
|
+
finishedAt: new Date().toISOString(),
|
|
130
|
+
durationMs: Number(logEntry.query_duration_ms),
|
|
131
|
+
error: logEntry.exception,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return updated;
|
|
138
|
+
}
|
|
139
|
+
async function pollChunk(executor, initial, pollIntervalMs, maxPollErrors, onChanged) {
|
|
140
|
+
let state = initial;
|
|
141
|
+
let consecutiveErrors = 0;
|
|
142
|
+
while (state.status === 'submitted' || state.status === 'running') {
|
|
143
|
+
await sleep(pollIntervalMs);
|
|
144
|
+
if (!state.queryId)
|
|
145
|
+
break;
|
|
146
|
+
let qs;
|
|
147
|
+
try {
|
|
148
|
+
qs = await executor.queryStatus(state.queryId, {
|
|
149
|
+
afterTime: state.submittedAt,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
consecutiveErrors++;
|
|
154
|
+
if (consecutiveErrors >= maxPollErrors) {
|
|
155
|
+
state = {
|
|
156
|
+
...state,
|
|
157
|
+
status: 'failed',
|
|
158
|
+
finishedAt: new Date().toISOString(),
|
|
159
|
+
error: `Lost contact with query after ${consecutiveErrors} consecutive poll errors`,
|
|
160
|
+
};
|
|
161
|
+
await onChanged(state);
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
consecutiveErrors = 0;
|
|
167
|
+
const result = applyQueryStatus(state, qs);
|
|
168
|
+
if (result.changed) {
|
|
169
|
+
state = result.state;
|
|
170
|
+
await onChanged(state);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return state;
|
|
174
|
+
}
|
|
175
|
+
export async function executeBackfill(options) {
|
|
176
|
+
const { executor, planId, chunks, buildQuery, concurrency = 3, pollIntervalMs = 5000, maxPollErrors = 10, onProgress, resumeFrom, replayFailed, } = options;
|
|
177
|
+
let progress = Object.fromEntries(chunks.map((chunk) => {
|
|
178
|
+
const resumed = resumeFrom?.[chunk.id];
|
|
179
|
+
return [chunk.id, resumed ? { ...resumed } : { status: 'pending' }];
|
|
180
|
+
}));
|
|
181
|
+
// When resuming, reconcile local state with the server before processing.
|
|
182
|
+
// This catches queries that were submitted but whose status was never
|
|
183
|
+
// persisted (e.g. client crash between submit() and state file write).
|
|
184
|
+
if (resumeFrom) {
|
|
185
|
+
progress = await syncProgress(executor, planId, chunks, progress);
|
|
186
|
+
}
|
|
187
|
+
// Reset confirmed-failed chunks to pending AFTER sync so we operate on
|
|
188
|
+
// ground truth. The deterministic query_id is reused; the afterTime filter
|
|
189
|
+
// in queryStatus ensures we ignore stale query_log entries from prior attempts.
|
|
190
|
+
if (replayFailed) {
|
|
191
|
+
// Stamp submittedAt with a 60s buffer so the afterTime filter in
|
|
192
|
+
// queryStatus ignores stale query_log entries from the prior failed
|
|
193
|
+
// attempt while tolerating clock skew between client and server.
|
|
194
|
+
const replayAfterTime = new Date(Date.now() - 60_000).toISOString();
|
|
195
|
+
for (const chunk of chunks) {
|
|
196
|
+
const state = progress[chunk.id];
|
|
197
|
+
if (state?.status === 'failed') {
|
|
198
|
+
progress = updateChunk(progress, chunk.id, { status: 'pending', submittedAt: replayAfterTime });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// Persist the reconciled state so the caller's checkpoint is up to date
|
|
203
|
+
if (resumeFrom || replayFailed) {
|
|
204
|
+
await onProgress?.(progress);
|
|
205
|
+
}
|
|
206
|
+
const setChunk = (id, next) => {
|
|
207
|
+
progress = updateChunk(progress, id, next);
|
|
208
|
+
return onProgress?.(progress);
|
|
209
|
+
};
|
|
210
|
+
await pMap(chunks, async (chunk) => {
|
|
211
|
+
const state = getChunk(progress, chunk.id);
|
|
212
|
+
// Already terminal from a previous run
|
|
213
|
+
if (state.status === 'done' || state.status === 'failed')
|
|
214
|
+
return;
|
|
215
|
+
// Resumed in-flight: poll to completion
|
|
216
|
+
if (state.status === 'submitted' || state.status === 'running') {
|
|
217
|
+
if (!state.queryId) {
|
|
218
|
+
await setChunk(chunk.id, { ...state, status: 'pending' });
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
await pollChunk(executor, state, pollIntervalMs, maxPollErrors, (s) => setChunk(chunk.id, s));
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// Submit and poll
|
|
226
|
+
// submittedAt is intentionally omitted on first submission — it's only
|
|
227
|
+
// used as an afterTime filter to ignore stale query_log entries when
|
|
228
|
+
// replaying a previously failed chunk with the same deterministic query_id.
|
|
229
|
+
// Setting it to local time here would cause clock-skew issues with the
|
|
230
|
+
// ClickHouse server, making the filter exclude valid entries.
|
|
231
|
+
const queryId = chunkQueryId(planId, chunk.id);
|
|
232
|
+
const sql = buildQuery(chunk);
|
|
233
|
+
await executor.submit(sql, queryId);
|
|
234
|
+
const submitted = {
|
|
235
|
+
...getChunk(progress, chunk.id),
|
|
236
|
+
status: 'submitted',
|
|
237
|
+
queryId,
|
|
238
|
+
};
|
|
239
|
+
await setChunk(chunk.id, submitted);
|
|
240
|
+
await pollChunk(executor, submitted, pollIntervalMs, maxPollErrors, (s) => setChunk(chunk.id, s));
|
|
241
|
+
}, { concurrency });
|
|
242
|
+
const completed = chunks.filter((c) => getChunk(progress, c.id).status === 'done').length;
|
|
243
|
+
const failed = chunks.filter((c) => getChunk(progress, c.id).status === 'failed').length;
|
|
244
|
+
return {
|
|
245
|
+
total: chunks.length,
|
|
246
|
+
completed,
|
|
247
|
+
failed,
|
|
248
|
+
progress,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=async-backfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-backfill.js","sourceRoot":"","sources":["../src/async-backfill.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,OAAO,CAAA;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S,GAAuB;YACpC,GAAG,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,EAAE,WAAW;YACnB,OAAO;SACR,CAAA;QACD,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,CAAA;QAEnC,MAAM,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;IACnG,CAAC,EACD,EAAE,WAAW,EAAE,CAChB,CAAA;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM,CAAA;IACzF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,MAAM,CAAA;IAExF,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,SAAS;QACT,MAAM;QACN,QAAQ;KACT,CAAA;AACH,CAAC"}
|
package/dist/check.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ResolvedChxConfig } from '@chkit/core';
|
|
2
|
+
import type { BackfillPluginCheckResult } from './types.js';
|
|
3
|
+
export declare function evaluateBackfillCheck(input: {
|
|
4
|
+
configPath: string;
|
|
5
|
+
config: Pick<ResolvedChxConfig, 'metaDir'>;
|
|
6
|
+
stateDir?: string;
|
|
7
|
+
failCheckOnRequiredPendingBackfill: boolean;
|
|
8
|
+
}): Promise<BackfillPluginCheckResult>;
|
|
9
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAOpD,OAAO,KAAK,EACV,yBAAyB,EAC1B,MAAM,YAAY,CAAA;AAEnB,wBAAsB,qBAAqB,CAAC,KAAK,EAAE;IACjD,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAA;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kCAAkC,EAAE,OAAO,CAAA;CAC5C,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAgFrC"}
|