Skip to content

Commit fc3257d

Browse files
committed
test(plugin-pinyin-search): port the boot-reconcile batching and suite budget fix
Test Core (8/8) failed twice on this PR in plugin-pinyin-search's boot-reconcile.integration.test.ts, as it does on other open PRs: the fixture seeds 2,500 rows one awaited create at a time and the suite overruns vitest's 5 s default under CI load. The same change as the open fix PR 25775 is ported here; it no-ops once main carries that PR. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VEz8GXcBLFWiasohtBhYgR
1 parent 48cfe29 commit fc3257d

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

‎packages/plugins/plugin-pinyin-search/src/boot-reconcile.integration.test.ts‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const SYSTEM = { isSystem: true } as const;
3737
const HISTORIC = '2026-01-01T00:00:00.000Z';
3838
const ROWS = 2_500;
3939
const PAGE = 1_000;
40+
/** SQLite's compound-SELECT ceiling: the most rows one `bulkCreate` can carry. */
41+
const INSERT_BATCH = 500;
4042

4143
const PROBE_OBJECT = {
4244
name: PROBE,
@@ -98,9 +100,19 @@ class FixturePlugin implements Plugin {
98100
};
99101
}
100102

101-
/** A write that bypasses every hook and the audit stamp: an import, a migration. */
103+
/**
104+
* A write that bypasses every hook and the audit stamp: an import, a migration.
105+
* Batched `bulkCreate`, not one awaited `create` per row (#25749): 2,500
106+
* single-row autocommit inserts timed these cases out under CI load. A batch
107+
* is one `… UNION ALL SELECT …` statement on SQLite, which refuses more than
108+
* 500 terms ("too many terms in compound SELECT"), hence the slices. The
109+
* driver keeps the given `created_at`/`updated_at`, so the history stays older
110+
* than any watermark.
111+
*/
102112
async directInsert(rows: Array<Record<string, unknown>>): Promise<void> {
103-
for (const row of rows) await this.driver.create(PROBE, row);
113+
for (let i = 0; i < rows.length; i += INSERT_BATCH) {
114+
await this.driver.bulkCreate(PROBE, rows.slice(i, i + INSERT_BATCH));
115+
}
104116
}
105117

106118
async row(id: string): Promise<Record<string, any> | null> {
@@ -167,7 +179,12 @@ function history(): Array<Record<string, unknown>> {
167179
}));
168180
}
169181

170-
describe('#25634 the boot reconcile reads what changed since its last completed walk', () => {
182+
// [#25749] Each case pays for real-kernel boots over a SQLite file (two in
183+
// most) and at least one full 2,500-row reconcile walk; the forced-rebuild
184+
// case walks twice. Idle, the slowest case takes about 1 s. On a 4-core box
185+
// with 20 busy loops the boots and walks alone took 6.8 s and 10.1 s (seed
186+
// excluded), past vitest's 5 s default, so the suite carries its own budget.
187+
describe('#25634 the boot reconcile reads what changed since its last completed walk', { timeout: 30_000 }, () => {
171188
it('a first boot walks every row; an unchanged second boot reads none — and a receipt sits in sys_migration', async () => {
172189
const first = await boot({ before: (f) => f.directInsert(history()) });
173190
await first.plugin.whenReconciled();

0 commit comments

Comments
 (0)