mirror of
https://github.com/whyour/qinglong.git
synced 2026-11-30 16:27:21 +08:00
Share durable permits across manual, scheduled and recovered runs, prioritize short ready tasks with aging, and record global queue occupancy. Reduce launch, log polling, dashboard and SQLite overhead while preserving transactional receipts, cancellation, recovery and script hook compatibility. Keep ordinary CRUD in ORM and bound SQL on measured execution hot paths. Fix supervisor descendant tracking, asynchronous log draining, concurrent log directory creation, Linux fallback launches and snapshot clock rollback. Include regression coverage, SQL audits and evolution/review documentation. Validation: five review rounds; local full suite 1478 passed, 28 platform skips; dev suites 415 passed, no failures/skips; backend types and formatting passed.
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs/promises');
|
|
const os = require('node:os');
|
|
const path = require('node:path');
|
|
const { spawn } = require('node:child_process');
|
|
const { once } = require('node:events');
|
|
const test = require('node:test');
|
|
|
|
for (const mode of ['commit', 'rollback']) {
|
|
test(
|
|
`32 competing SQLite writers preserve progress, exact writes and ${mode}`,
|
|
{ timeout: 35000 },
|
|
async (t) => {
|
|
const root = await fs.mkdtemp(
|
|
path.join(os.tmpdir(), 'ql-sqlite-contention-'),
|
|
);
|
|
const child = spawn(
|
|
process.execPath,
|
|
[path.resolve('test/helpers/sqlite-contention-worker.cjs'), root, mode],
|
|
{
|
|
env: { ...process.env, UV_THREADPOOL_SIZE: '4' },
|
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
},
|
|
);
|
|
t.after(async () => {
|
|
child.kill('SIGKILL');
|
|
await fs.rm(root, { recursive: true, force: true });
|
|
});
|
|
let output = '';
|
|
child.stdout.on('data', (data) => (output += data));
|
|
child.stderr.on('data', (data) => (output += data));
|
|
const watchdog = setTimeout(() => child.kill('SIGKILL'), 30000);
|
|
t.after(() => clearTimeout(watchdog));
|
|
const [code, signal] = await once(child, 'close');
|
|
assert.equal(signal, null, output);
|
|
assert.equal(code, 0, output);
|
|
assert.match(output, /"callbacks":32/);
|
|
},
|
|
);
|
|
}
|