@indigoai-us/hq-cloud 6.16.71-alpha.1 → 6.16.71
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/dist/bin/sync-runner-watch-loop.d.ts +5 -4
- package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +8 -20
- package/dist/bin/sync-runner-watch-loop.js.map +1 -1
- package/dist/bin/sync-runner.test.js +66 -17
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -20,7 +20,7 @@ import { PresignObjectIO, S3SdkObjectIO } from "../object-io.js";
|
|
|
20
20
|
import { setBandwidthGovernorForTesting } from "../bandwidth.js";
|
|
21
21
|
import { POST_SYNC_FLAG_KEYS, } from "./sync-runner-post-sync-flags.js";
|
|
22
22
|
import { FakeClock, TreeWatcher, } from "../watcher.js";
|
|
23
|
-
import { adaptivePollMs, advanceMonotonicDeadline, DEFAULT_EVENT_BATCH_LIMIT, DEFAULT_FAST_LANE_MAX_BYTES, DEFAULT_FAST_LANE_MAX_FILE_BYTES, DEFAULT_FAST_LANE_MAX_FILES, DEFAULT_FULL_RECONCILE_MS, EVENT_BATCH_LIMIT_ENV, FAST_LANE_MAX_BYTES_ENV, FAST_LANE_MAX_FILES_ENV, FULL_RECONCILE_MS_ENV, isFastLocalBatch, isFastReceiverBatch, partitionLocalBatch, journalEntriesForWatcherDelete, resolveEventBatchLimit, resolveFullReconcileMs, resolveWatchPollMs, CHORE_STARVATION_CAP_MS, CooperativePassScheduler, REALTIME_ADMISSION_DEADLINE_MS, REALTIME_DRAIN_BURST_MS, RealtimeAdmissionTimeoutError,
|
|
23
|
+
import { adaptivePollMs, advanceMonotonicDeadline, DEFAULT_EVENT_BATCH_LIMIT, DEFAULT_FAST_LANE_MAX_BYTES, DEFAULT_FAST_LANE_MAX_FILE_BYTES, DEFAULT_FAST_LANE_MAX_FILES, DEFAULT_FULL_RECONCILE_MS, EVENT_BATCH_LIMIT_ENV, FAST_LANE_MAX_BYTES_ENV, FAST_LANE_MAX_FILES_ENV, FULL_RECONCILE_MS_ENV, isFastLocalBatch, isFastReceiverBatch, partitionLocalBatch, journalEntriesForWatcherDelete, resolveEventBatchLimit, resolveFullReconcileMs, resolveWatchPollMs, CHORE_STARVATION_CAP_MS, CooperativePassScheduler, REALTIME_ADMISSION_DEADLINE_MS, REALTIME_DRAIN_BURST_MS, RealtimeAdmissionTimeoutError, setRealtimeAdmissionDeadlineMsForTesting, setRealtimeDrainBurstMsForTesting, normalizeCoordinatorPaths, shouldQuarantineWatcherDeleteIntents, shouldUseAreaStorage, WATCHER_REDISCOVERY_RETRY_MS, WATCHER_REDISCOVERY_RETRY_MAX_MS, } from "./sync-runner-watch-loop.js";
|
|
24
24
|
import { FullPassCapController, resetFullPassCapLogForTest, } from "../sync/full-pass-caps.js";
|
|
25
25
|
import { AreaLedgerMigration, JournalStore, openJournalStateStoreForMigration, PERSONAL_VAULT_JOURNAL_SLUG, readJournal, readJournalScoped, writeJournal, } from "../journal.js";
|
|
26
26
|
import { AreaLedger } from "../sync/area-ledger.js";
|
|
@@ -9262,10 +9262,11 @@ describe("CooperativePassScheduler", () => {
|
|
|
9262
9262
|
"realtime-after-cap",
|
|
9263
9263
|
]);
|
|
9264
9264
|
});
|
|
9265
|
-
it("
|
|
9265
|
+
it("lets an in-flight realtime drain finish past the burst bound and admits no further items until the next checkpoint", async () => {
|
|
9266
9266
|
expect(REALTIME_DRAIN_BURST_MS).toBe(REALTIME_ADMISSION_DEADLINE_MS);
|
|
9267
9267
|
setRealtimeDrainBurstMsForTesting(40);
|
|
9268
|
-
|
|
9268
|
+
let now = 0;
|
|
9269
|
+
const scheduler = new CooperativePassScheduler(() => now);
|
|
9269
9270
|
const order = [];
|
|
9270
9271
|
let releaseCheckpoint = () => { };
|
|
9271
9272
|
const checkpointReady = new Promise((resolve) => {
|
|
@@ -9281,34 +9282,82 @@ describe("CooperativePassScheduler", () => {
|
|
|
9281
9282
|
return 0;
|
|
9282
9283
|
}, "chore");
|
|
9283
9284
|
await Promise.resolve();
|
|
9284
|
-
const
|
|
9285
|
-
const realtime = scheduler.submit(async ({ signal }) => {
|
|
9285
|
+
const first = scheduler.submit(async ({ signal }) => {
|
|
9286
9286
|
order.push("realtime-start");
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
clearTimeout(timer);
|
|
9291
|
-
reject(new RealtimeDrainBurstError(40));
|
|
9292
|
-
};
|
|
9293
|
-
if (signal.aborted)
|
|
9294
|
-
onAbort();
|
|
9295
|
-
else
|
|
9296
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
9287
|
+
now = 45;
|
|
9288
|
+
await new Promise((resolve) => {
|
|
9289
|
+
setTimeout(resolve, 60);
|
|
9297
9290
|
});
|
|
9291
|
+
expect(signal.aborted).toBe(false);
|
|
9292
|
+
order.push("realtime-done");
|
|
9293
|
+
return 0;
|
|
9294
|
+
}, "realtime");
|
|
9295
|
+
const second = scheduler.submit(async () => {
|
|
9296
|
+
order.push("realtime-second");
|
|
9298
9297
|
return 0;
|
|
9299
9298
|
}, "realtime");
|
|
9300
9299
|
await new Promise((resolve) => setTimeout(resolve, 2));
|
|
9301
9300
|
releaseCheckpoint();
|
|
9302
|
-
await expect(
|
|
9301
|
+
await expect(first).resolves.toBe(0);
|
|
9303
9302
|
await chore;
|
|
9304
|
-
|
|
9303
|
+
await second;
|
|
9305
9304
|
expect(order).toEqual([
|
|
9306
9305
|
"chore-before",
|
|
9307
9306
|
"realtime-start",
|
|
9307
|
+
"realtime-done",
|
|
9308
9308
|
"chore-mid",
|
|
9309
|
+
"realtime-second",
|
|
9309
9310
|
"chore-after",
|
|
9310
9311
|
]);
|
|
9311
9312
|
});
|
|
9313
|
+
it("does not abort or retry a 45s in-flight realtime PUT when the drain burst is 30s", async () => {
|
|
9314
|
+
expect(REALTIME_DRAIN_BURST_MS).toBe(30_000);
|
|
9315
|
+
vi.useFakeTimers();
|
|
9316
|
+
try {
|
|
9317
|
+
let now = 0;
|
|
9318
|
+
const scheduler = new CooperativePassScheduler(() => now);
|
|
9319
|
+
const order = [];
|
|
9320
|
+
let abortCount = 0;
|
|
9321
|
+
let releaseCheckpoint = () => { };
|
|
9322
|
+
const checkpointReady = new Promise((resolve) => {
|
|
9323
|
+
releaseCheckpoint = resolve;
|
|
9324
|
+
});
|
|
9325
|
+
const chore = scheduler.submit(async ({ checkpoint }) => {
|
|
9326
|
+
order.push("chore-before");
|
|
9327
|
+
await checkpointReady;
|
|
9328
|
+
await checkpoint();
|
|
9329
|
+
order.push("chore-after");
|
|
9330
|
+
return 0;
|
|
9331
|
+
}, "chore");
|
|
9332
|
+
await Promise.resolve();
|
|
9333
|
+
const put = scheduler.submit(async ({ signal }) => {
|
|
9334
|
+
order.push("put-start");
|
|
9335
|
+
signal.addEventListener("abort", () => {
|
|
9336
|
+
abortCount += 1;
|
|
9337
|
+
}, { once: true });
|
|
9338
|
+
now = 45_000;
|
|
9339
|
+
await new Promise((resolve) => {
|
|
9340
|
+
setTimeout(resolve, 45_000);
|
|
9341
|
+
});
|
|
9342
|
+
order.push("put-done");
|
|
9343
|
+
return 0;
|
|
9344
|
+
}, "realtime");
|
|
9345
|
+
releaseCheckpoint();
|
|
9346
|
+
const finished = Promise.all([chore, put]);
|
|
9347
|
+
await vi.advanceTimersByTimeAsync(45_000);
|
|
9348
|
+
await expect(finished).resolves.toEqual([0, 0]);
|
|
9349
|
+
expect(abortCount).toBe(0);
|
|
9350
|
+
expect(order).toEqual([
|
|
9351
|
+
"chore-before",
|
|
9352
|
+
"put-start",
|
|
9353
|
+
"put-done",
|
|
9354
|
+
"chore-after",
|
|
9355
|
+
]);
|
|
9356
|
+
}
|
|
9357
|
+
finally {
|
|
9358
|
+
vi.useRealTimers();
|
|
9359
|
+
}
|
|
9360
|
+
});
|
|
9312
9361
|
afterEach(() => {
|
|
9313
9362
|
setRealtimeAdmissionDeadlineMsForTesting(undefined);
|
|
9314
9363
|
setRealtimeDrainBurstMsForTesting(undefined);
|