@@ -696,25 +703,64 @@ async function buildIndexes(btn) {
btn.disabled = true;
try {
const r = await fetch('/control/build-indexes', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' }).then(x => x.json());
- toast(r.started ? '\u2705 Index builds started (' + r.missing + ' collection(s))' : (r.missing === 0 ? '\u2705 All collections already indexed' : '\u26a0\ufe0f Build already running'));
+ toast(r.started
+ ? '\u2705 Index builds started (' + r.missing + ' collection(s)' + (r.inProgress ? ', ' + r.inProgress + ' already in progress' : '') + ')'
+ : (r.missing === 0 ? '\u2705 All collections already indexed' : '\u26a0\ufe0f Build already running'));
pollIndexProgress();
} catch (e) { toast('\u274c ' + e.message); }
btn.disabled = false;
}
-let idxTimer = null;
+function idxPhaseText(op, phases) {
+ return (op.phase ? 'step ' + op.phase + ' of ' + phases + ': ' : '') + op.phaseLabel +
+ (op.pct != null ? ' \u00b7 ' + op.pct + '% (' + fmt(op.done) + ' / ' + fmt(op.total) + ')' : '') +
+ // behind mongos each shard builds its own part; the run waits for the slowest
+ (op.shards > 1 ? ' \u00b7 slowest of ' + op.shards + ' shards still building: ' + op.shard
+ : (op.shard ? ' \u00b7 shard ' + op.shard : ''));
+}
+// Driven by slowTick: covers builds the run starts itself while mapping,
+// not only the ones started from the button.
async function pollIndexProgress() {
const p = await fetch('/api/index-progress').then(r => r.json()).catch(() => null);
if (!p) return;
- const el = document.getElementById('idx-progress');
+ const ops = p.serverOps || [];
const rows = [];
if (p.total > 0) rows.push('
' + (p.running ? '\u23f3' : (p.error ? '\u274c' : '\u2705')) + '' +
p.done.length + '/' + p.total + ' built' + esc(p.current ? 'building: ' + p.current : (p.error || 'idle')) + '
');
- for (const op of p.serverOps || []) {
- rows.push('
\u23f3' + esc(op.collection) + '' + (op.pct != null ? op.pct + '%' : esc(op.msg || 'in progress')) + '
');
+ for (const op of ops) {
+ rows.push('
\u23f3' + esc(op.collection) + '' + esc(idxPhaseText(op, p.phases)) + '
');
+ }
+ document.getElementById('idx-progress').innerHTML = rows.join('');
+
+ // Overview bar: the build the run is blocked on first, then a button
+ // build, then any other in-flight build on the source db.
+ const box = document.getElementById('index-progress');
+ const target = p.auto ? p.auto.collection : (p.running && p.current ? p.current : (ops[0] ? ops[0].collection : null));
+ const op = target ? ops.find(o => o.collection === target) || null : null;
+ // ensureIndex on an already-built index returns in milliseconds \u2014 do not
+ // flash the bar for it
+ const blip = p.auto && !op && Date.now() - p.auto.startedAtMs < 3000;
+ document.getElementById('ph2-s').textContent = target && !blip ? 'building\u2026' : 'auto';
+ if (!target || blip) { box.style.display = 'none'; return; }
+ box.style.display = '';
+ document.getElementById('index-progress-title').textContent = 'Building {cd:1,_id:1} index on ' + target +
+ (p.auto && p.auto.of ? ' \u2014 collection ' + p.auto.position + ' of ' + p.auto.of
+ : (!p.auto && p.running ? ' \u2014 ' + (p.done.length + 1) + ' of ' + p.total + ' (started from Guide step 2)' : ''));
+ const fill = document.getElementById('index-progress-fill');
+ if (op && op.pct != null) {
+ fill.style.width = op.pct + '%';
+ fill.style.animation = '';
+ } else {
+ fill.style.width = '100%';
+ fill.style.animation = 'pulse 1.2s ease-in-out infinite';
}
- el.innerHTML = rows.join('');
- if (p.running && !idxTimer) { idxTimer = setInterval(pollIndexProgress, 3000); }
- if (!p.running && idxTimer) { clearInterval(idxTimer); idxTimer = null; }
+ document.getElementById('index-progress-text').textContent =
+ (op ? idxPhaseText(op, p.phases)
+ : 'no server-side progress visible' + (p.serverOpsError ? ': ' + p.serverOpsError : ' (the build may run on another member)')) +
+ (p.auto ? ' \u00b7 waiting ' + fmtWait(Date.now() - p.auto.startedAtMs) + ' \u00b7 chunk copying starts once the index is ready' : '');
+}
+function fmtWait(ms) {
+ const m = Math.max(0, Math.floor(ms / 60000));
+ return m >= 60 ? Math.floor(m / 60) + 'h ' + (m % 60) + 'm' : (m > 0 ? m + 'm' : Math.floor(ms / 1000) + 's');
}
async function startDry(btn) {
btn.disabled = true;
@@ -1305,6 +1351,7 @@ async function pollBoundary(btn) {
// digits as a string, and unquoted they looked like a no-op in the UI
function fmtVal(v) { return typeof v === 'string' ? '"' + esc(v) + '"' : esc(String(v)); }
async function slowTick() {
+ pollIndexProgress().catch(() => {});
try {
const [dlq, report, replay] = await Promise.all([
fetch('/api/dlq?offset=' + dlqOffset).then(r => r.json()),
diff --git a/src/runtime/chunk-orchestrator.ts b/src/runtime/chunk-orchestrator.ts
index b852777..bbaa389 100644
--- a/src/runtime/chunk-orchestrator.ts
+++ b/src/runtime/chunk-orchestrator.ts
@@ -36,6 +36,7 @@ import { SkipCounter, SkipReason } from '../transform/skip-reasons.ts';
import { CoercionCounter } from '../transform/coercions.ts';
import { classifyError } from './error-classifier.ts';
import { discoverCollections } from '../source/discover-collections.ts';
+import { parseIndexBuildOps, INDEX_BUILD_PHASES, type IndexBuildOp } from '../source/index-build-ops.ts';
import type { Cursor } from '../types/cursor.ts';
import { createHash } from 'node:crypto';
import { setTimeout as sleep } from 'node:timers/promises';
@@ -52,6 +53,14 @@ export interface ChunkOrchestratorDeps {
chPressure?: ClickHousePressure;
}
+/** Mapping is blocked on this collection's {cd,_id} index (position/of: null outside the map pass). */
+export interface AutoIndexState {
+ collection: string;
+ position: number | null;
+ of: number | null;
+ startedAtMs: number;
+}
+
export interface LedgerEngineStats {
engine: 'ledger';
runId: string;
@@ -534,9 +543,9 @@ export class ChunkOrchestrator {
return !(d2 && skipEventNames.has(d2.e));
});
}
- for (const collection of collections) {
+ for (const [i, collection] of collections.entries()) {
if (this.stopping) break;
- newChunks += await this.mapCollection(collection);
+ newChunks += await this.mapCollection(collection, { position: i + 1, of: collections.length });
}
if (mapPass === 0) {
this.logger.info({ mapped: this.collectionDefaults.size }, 'All collections mapped — global claiming starts');
@@ -653,7 +662,7 @@ export class ChunkOrchestrator {
* bounds, cut the chunk grid (+ null-cd sentinel), persist it idempotently.
* No copying happens here — claims are global afterwards.
*/
- private async mapCollection(collection: string): Promise
{
+ private async mapCollection(collection: string, at?: { position: number; of: number }): Promise {
const { config, mongoReader, ledger } = this.d;
this.currentCollection = collection; // mapping progress visible in UI
const log = this.logger.child({ collection });
@@ -662,7 +671,16 @@ export class ChunkOrchestrator {
if (!(await mongoReader.hasRequiredIndex(collection))) {
log.info('Building {cd:1,_id:1} index (this can take a long time on large collections — progress in the UI)');
}
- await mongoReader.ensureIndex(collection);
+ // State is set around ensureIndex itself, not the check above: an
+ // in-progress build (another pod's, the UI button's, or one a restart
+ // left behind) is listed as present, yet ensureIndex joins and blocks
+ // on it all the same.
+ this.autoIndex = { collection, position: at?.position ?? null, of: at?.of ?? null, startedAtMs: Date.now() };
+ try {
+ await mongoReader.ensureIndex(collection);
+ } finally {
+ this.autoIndex = null;
+ }
const defaults = this.d.hashResolver.resolveCollectionName(collection, config.source.collectionPrefix) ?? undefined;
this.collectionDefaults.set(collection, defaults);
@@ -2219,18 +2237,32 @@ export class ChunkOrchestrator {
private indexBuild: { running: boolean; total: number; done: string[]; current: string | null; error: string | null } =
{ running: false, total: 0, done: [], current: null, error: null };
- /** Kick off {cd,_id} index builds on all collections missing it (background). */
- async startIndexBuilds(): Promise<{ started: boolean; missing: number }> {
- if (this.indexBuild.running) return { started: false, missing: this.indexBuild.total - this.indexBuild.done.length };
+ /** The index build the run itself is blocked on during mapping (null when not waiting). */
+ private autoIndex: AutoIndexState | null = null;
+
+ autoIndexState(): AutoIndexState | null {
+ return this.autoIndex;
+ }
+
+ /**
+ * Kick off {cd,_id} index builds on all collections missing it (background).
+ * Builds already in flight are listed as present, so they are joined too —
+ * otherwise the button reports "all indexed" while a build is running.
+ */
+ async startIndexBuilds(): Promise<{ started: boolean; missing: number; inProgress: number }> {
+ if (this.indexBuild.running) return { started: false, missing: this.indexBuild.total - this.indexBuild.done.length, inProgress: 0 };
const db = this.d.mongoReader.getDatabase();
const collections = await discoverCollections(db, this.d.config.source.collectionPrefix, this.logger);
+ const inFlight = new Set((await this.currentIndexBuildOps()).ops.map((op) => op.collection));
const missing: string[] = [];
+ let inProgress = 0;
for (const name of collections) {
const idx = await db.collection(name).indexes().catch(() => []);
const has = idx.some((i) => (i.key as Record).cd !== undefined && (i.key as Record)._id !== undefined);
if (!has) missing.push(name);
+ else if (inFlight.has(name)) { missing.push(name); inProgress++; }
}
- if (missing.length === 0) return { started: false, missing: 0 };
+ if (missing.length === 0) return { started: false, missing: 0, inProgress: 0 };
this.indexBuild = { running: true, total: missing.length, done: [], current: null, error: null };
void (async () => {
@@ -2247,30 +2279,38 @@ export class ChunkOrchestrator {
this.indexBuild.running = false;
this.indexBuild.current = null;
})();
- return { started: true, missing: missing.length };
+ return { started: true, missing: missing.length, inProgress };
}
- /** Index-build progress incl. live server-side build progress via $currentOp. */
- async indexBuildProgress(): Promise> {
- let serverOps: Array<{ collection: string; pct: number | null; msg: string }> = [];
+ /**
+ * In-flight {cd,_id} builds on the source db, from $currentOp. Progress is
+ * best-effort (it needs the inprog privilege), so a failure is returned,
+ * not thrown — but never swallowed: a silent [] hid the readConcern bug.
+ */
+ private async currentIndexBuildOps(): Promise<{ ops: IndexBuildOp[]; error: string | null }> {
try {
- const adminDb = this.d.mongoReader.getDatabase().client.db('admin');
- const ops = await adminDb
+ const db = this.d.mongoReader.getDatabase();
+ const ops = await db.client.db('admin')
.aggregate([
{ $currentOp: { allUsers: true } },
{ $match: { 'command.createIndexes': { $exists: true } } },
- { $project: { command: 1, progress: 1, msg: 1 } },
- ])
+ { $project: { ns: 1, command: 1, progress: 1, msg: 1, shard: 1 } },
+ ], {
+ // $currentOp refuses any readConcern but 'local', and the source
+ // client defaults to 'majority' (MONGO_READ_CONCERN)
+ readConcern: { level: 'local' },
+ })
.toArray();
- serverOps = ops.map((o: Record) => ({
- collection: String((o.command as Record)?.createIndexes ?? '?'),
- pct: o.progress && (o.progress as Record).total
- ? Math.round(((o.progress as Record).done / (o.progress as Record).total) * 100)
- : null,
- msg: String(o.msg ?? ''),
- }));
- } catch { /* $currentOp may need privileges — progress is then best-effort */ }
- return { ...this.indexBuild, serverOps };
+ return { ops: parseIndexBuildOps(ops, db.databaseName), error: null };
+ } catch (err) {
+ return { ops: [], error: (err as Error).message };
+ }
+ }
+
+ /** Index-build progress: UI-button builds, the run's own mapping-time wait, and live server-side progress. */
+ async indexBuildProgress(): Promise> {
+ const server = await this.currentIndexBuildOps();
+ return { ...this.indexBuild, auto: this.autoIndex, phases: INDEX_BUILD_PHASES, serverOps: server.ops, serverOpsError: server.error };
}
// -------------------------------------------------------------------------
diff --git a/src/runtime/ledger-engine.ts b/src/runtime/ledger-engine.ts
index 4869ce4..2162496 100644
--- a/src/runtime/ledger-engine.ts
+++ b/src/runtime/ledger-engine.ts
@@ -139,6 +139,8 @@ export async function runLedgerEngine(config: Config, logger: Logger): Promise | null; error: string | null } =
{ status: 'not_run', stats: null, error: null };
+ // a dry run maps — and so builds missing indexes — on its own orchestrator
+ let dryOrchestrator: ChunkOrchestrator | null = null;
async function startDryRun(): Promise<{ started: boolean; reason?: string }> {
if (dryState.status === 'running') return { started: false, reason: 'dry run already running' };
@@ -171,6 +173,7 @@ export async function runLedgerEngine(config: Config, logger: Logger): Promise;
dryState.status = 'completed';
@@ -178,6 +181,7 @@ export async function runLedgerEngine(config: Config, logger: Logger): Promise {});
await dryStaging.close().catch(() => {});
}
@@ -378,7 +382,10 @@ export async function runLedgerEngine(config: Config, logger: Logger): Promise orchestrator.startIndexBuilds());
- app.get('/api/index-progress', async () => orchestrator.indexBuildProgress());
+ app.get('/api/index-progress', async () => {
+ const progress = await orchestrator.indexBuildProgress();
+ return progress.auto ? progress : { ...progress, auto: dryOrchestrator?.autoIndexState() ?? null };
+ });
app.post('/control/dry-run', async () => startDryRun());
app.post<{ Body: { force?: boolean } }>('/control/rebuild-ledger', async (req) => startRebuild(req.body?.force === true));
app.get('/api/rebuild', async () => rebuildState);
diff --git a/src/source/index-build-ops.ts b/src/source/index-build-ops.ts
new file mode 100644
index 0000000..4556571
--- /dev/null
+++ b/src/source/index-build-ops.ts
@@ -0,0 +1,127 @@
+/**
+ * Live {cd:1,_id:1} index-build progress from `$currentOp` output.
+ *
+ * A createIndex shows up as TWO ops (verified on MongoDB 8.0): the
+ * client connection waiting on the build (no progress fields) and the
+ * builder thread `IndexBuildsCoordinatorMongod-N` carrying
+ * `progress {done,total}` and a `msg` naming the phase. The percentage
+ * restarts per phase — "scanning collection" (docs), then "inserting keys
+ * from external sorter into index" (keys), then a short "draining writes
+ * received during build" — so a bare percentage jumps 100% → 0% mid-build;
+ * the phase travels with it.
+ *
+ * Between the two counted phases the builder keeps saying "scanning
+ * collection" WITHOUT counters while it sorts the keys: 30–45% of the whole
+ * build in every capture (replica-set primary and secondary), and
+ * never before the scan's counters appear. That state is its own step, so
+ * the bar does not sit on "scanning documents" long after the scan ended.
+ *
+ * Through mongos every shard reports its own builder op (tagged `shard`),
+ * with `total` = that shard's documents; the run waits for all of them, so
+ * the least advanced shard is reported along with the shard count. On a
+ * secondary the builder op carries no `command.$db`, hence the `ns` fallback.
+ * Pure; the orchestrator runs the aggregation.
+ */
+
+export interface IndexBuildOp {
+ collection: string;
+ /** 1 = scanning documents, 2 = sorting keys, 3 = writing index keys, 4 = draining writes, null = unknown */
+ phase: 1 | 2 | 3 | 4 | null;
+ phaseLabel: string;
+ done: number | null;
+ total: number | null;
+ /** percentage of the CURRENT phase */
+ pct: number | null;
+ /** the raw server message — kept for the unknown-phase case */
+ msg: string;
+ /** shard of the reported op (mongos only), else null */
+ shard: string | null;
+ /** distinct shards building this index (0 when not behind mongos) */
+ shards: number;
+}
+
+export const INDEX_BUILD_PHASES = 4;
+
+type Phase = { phase: 1 | 2 | 3 | 4; label: string };
+const PHASES: Array = [
+ { re: /scanning collection/i, phase: 1, label: 'scanning documents' },
+ { re: /external sorter|inserting keys/i, phase: 3, label: 'writing index keys' },
+ { re: /draining writes/i, phase: 4, label: 'applying writes made during the build' },
+];
+const SORTING: Phase = { phase: 2, label: 'sorting index keys (scan complete)' };
+
+function isCdIdIndex(spec: unknown): boolean {
+ const key = (spec as { key?: Record } | null)?.key;
+ if (!key) return false;
+ const names = Object.keys(key);
+ return names.length === 2 && names[0] === 'cd' && names[1] === '_id';
+}
+
+function parseOne(op: Record): IndexBuildOp {
+ const command = op.command as Record;
+ const msg = String(op.msg ?? '');
+ const progress = op.progress as { done?: number; total?: number } | undefined;
+ let hit: Phase | undefined = PHASES.find((p) => p.re.test(msg));
+ if (hit?.phase === 1 && progress === undefined) hit = SORTING;
+ const done = typeof progress?.done === 'number' ? progress.done : null;
+ const total = typeof progress?.total === 'number' && progress.total > 0 ? progress.total : null;
+ let phaseLabel = hit?.label ?? '';
+ if (!hit) {
+ // an unknown phase: show the server's own words; an op with no msg is a
+ // client waiting on a build whose builder thread is not visible from here
+ phaseLabel = msg.replace(/^Index Build:\s*/i, '').replace(/:\s*\d+\/\d+\s+\d+%$/, '').trim() || 'in progress';
+ }
+ return {
+ collection: String(command.createIndexes),
+ phase: hit?.phase ?? null,
+ phaseLabel,
+ done,
+ total,
+ pct: done !== null && total !== null ? Math.min(100, Math.round((done / total) * 100)) : null,
+ msg,
+ shard: typeof op.shard === 'string' ? op.shard : null,
+ shards: 0,
+ };
+}
+
+/**
+ * Least-advanced first: the slowest member/shard is what the run waits on.
+ * Within one phase an op without counters (seen at phase boundaries) never
+ * displaces one that has them.
+ */
+function lessAdvanced(a: IndexBuildOp, b: IndexBuildOp): boolean {
+ const pa = a.phase ?? 0;
+ const pb = b.phase ?? 0;
+ if (pa !== pb) return pa < pb;
+ if (a.pct === null) return false;
+ if (b.pct === null) return true;
+ return a.pct < b.pct;
+}
+
+/**
+ * One entry per collection with an in-flight {cd:1,_id:1} build in `dbName`.
+ * Builder ops win over waiter ops; among several builders (shards) the least
+ * advanced one is reported.
+ */
+export function parseIndexBuildOps(ops: Array>, dbName: string): IndexBuildOp[] {
+ const byColl = new Map }>();
+ for (const op of ops) {
+ const command = op.command as Record | undefined;
+ if (!command || typeof command.createIndexes !== 'string') continue;
+ const opDb = typeof command.$db === 'string' ? command.$db : String(op.ns ?? '').split('.')[0];
+ if (opDb !== dbName) continue;
+ if (!Array.isArray(command.indexes) || !command.indexes.some(isCdIdIndex)) continue;
+ const parsed = parseOne(op);
+ const builder = op.progress !== undefined || /^Index Build/i.test(parsed.msg);
+ let entry = byColl.get(parsed.collection);
+ if (!entry) {
+ entry = { op: parsed, builder, shards: new Set() };
+ byColl.set(parsed.collection, entry);
+ } else if ((builder && !entry.builder) || (builder === entry.builder && lessAdvanced(parsed, entry.op))) {
+ entry.op = parsed;
+ entry.builder = builder;
+ }
+ if (parsed.shard !== null) entry.shards.add(parsed.shard);
+ }
+ return [...byColl.values()].map((v) => ({ ...v.op, shards: v.shards.size }));
+}
diff --git a/tests/integration/index-build-progress.test.ts b/tests/integration/index-build-progress.test.ts
new file mode 100644
index 0000000..1bc2dce
--- /dev/null
+++ b/tests/integration/index-build-progress.test.ts
@@ -0,0 +1,226 @@
+/**
+ * Index-build progress reporting — the run's own mapping-time wait on the
+ * {cd:1,_id:1} index is visible, not only builds started from the button.
+ * Pinned here:
+ *
+ * - while mapping blocks on ensureIndex, autoIndexState / index-progress
+ * name the collection and its position in the map pass
+ * - the state clears once the index is ready, and the run completes with
+ * the index built on every collection
+ * - the state is set around ensureIndex even when the index is LISTED
+ * (an in-progress build lists as present but still blocks)
+ * - the button path builds missing indexes and reports completion
+ * - $currentOp works under the default readConcern 'majority' (it only
+ * accepts 'local'; the failure used to be swallowed into "no progress")
+ */
+import { describe, it, expect, beforeAll, afterAll } from 'vitest';
+import pino from 'pino';
+import { createHash } from 'node:crypto';
+import { MongoClient } from 'mongodb';
+import { createClient, type ClickHouseClient } from '@clickhouse/client';
+
+import { LedgerStore } from '../../src/state/ledger-store.ts';
+import { DlqStore } from '../../src/state/dlq-store.ts';
+import { StagingManager } from '../../src/target/staging-manager.ts';
+import { MongoReader } from '../../src/source/mongo-reader.ts';
+import { RetryPolicy } from '../../src/runtime/retry-policy.ts';
+import { HashResolver } from '../../src/transform/hash-resolver.ts';
+import { ChunkOrchestrator } from '../../src/runtime/chunk-orchestrator.ts';
+import { loadConfig } from '../../src/config/loader.ts';
+
+const MONGO_URI = 'mongodb://localhost:27017/?directConnection=true';
+const CH_URL = process.env.TEST_CLICKHOUSE_URL ?? 'http://localhost:8123';
+const CH_PASSWORD = process.env.TEST_CLICKHOUSE_PASSWORD ?? '';
+const DB = 'test_mig_idxprog';
+const logger = pino({ level: 'silent' });
+
+const APP = 'app_idx';
+const EVENTS = ['views', 'clicks'];
+const collOf = (ev: string): string => `drill_events${createHash('sha1').update(ev + APP).digest('hex')}`;
+const COLLS = EVENTS.map(collOf);
+const DOCS = 300;
+const sleep = (ms: number): Promise => new Promise((r) => setTimeout(r, ms));
+
+const hasCdIdIndex = async (mc: MongoClient, coll: string): Promise =>
+ (await mc.db(DB).collection(coll).indexes()).some((i) => i.name === 'cd_1__id_1');
+
+describe('index-build progress', () => {
+ let ch: ClickHouseClient;
+ let mc: MongoClient;
+ let ledger: LedgerStore;
+ let dlqStore: DlqStore;
+ let staging: StagingManager;
+ let hashResolver: HashResolver;
+ const closers: Array<() => Promise> = [];
+
+ const mkOrchestrator = async (runId: string): Promise<{ orch: ChunkOrchestrator; reader: MongoReader }> => {
+ Object.assign(process.env, {
+ SERVICE_NAME: 'idxprog-test',
+ MONGO_URI, MONGO_DB: DB, MONGO_COUNTLY_DB: `${DB}_countly`, MANIFEST_DB: DB,
+ CLICKHOUSE_URL: CH_URL, CLICKHOUSE_PASSWORD: CH_PASSWORD, CLICKHOUSE_DB: DB,
+ LEDGER_RUN_ID: runId, LEDGER_CHUNK_DOCS_TARGET: '400', MONGO_PAGE_SIZE: '200',
+ LEDGER_MONITOR_INTERVAL_MS: '0', BACKPRESSURE_ENABLED: 'false',
+ MULTI_POD_ENABLED: 'false', POD_ID: `${runId}-pod`, LEDGER_UNBOUNDED_OK: '1',
+ });
+ delete process.env.LEDGER_CD_UPPER_BOUND;
+ delete process.env.LEDGER_START_PAUSED;
+ const config = loadConfig();
+ const reader = new MongoReader({
+ // 'majority' is the MONGO_READ_CONCERN default — $currentOp refuses it
+ // unless the query pins 'local' itself
+ uri: MONGO_URI, database: DB, readPreference: 'primary', readConcern: 'majority',
+ retryReads: true, appName: runId, cursorBatchSize: 500, maxTimeMs: 60_000,
+ }, logger);
+ await reader.connect();
+ closers.push(() => reader.close());
+ const orch = new ChunkOrchestrator({
+ config, logger, mongoReader: reader, ledger, dlq: dlqStore, staging,
+ retryPolicy: new RetryPolicy({ maxRetries: 3, baseDelayMs: 100, maxDelayMs: 500 }), hashResolver,
+ });
+ return { orch, reader };
+ };
+
+ /** Hold every ensureIndex until released — a build that takes as long as the test wants. */
+ const gateEnsureIndex = (reader: MongoReader): { release: () => void; entered: string[] } => {
+ const entered: string[] = [];
+ let open: () => void = () => {};
+ let gate = new Promise((r) => { open = r; });
+ const real = reader.ensureIndex.bind(reader);
+ reader.ensureIndex = async (coll: string): Promise => {
+ entered.push(coll);
+ await gate;
+ await real(coll);
+ };
+ return {
+ entered,
+ release: () => { open(); gate = new Promise((r) => { open = r; }); },
+ };
+ };
+
+ const waitFor = async (cond: () => boolean, ms: number): Promise => {
+ const until = Date.now() + ms;
+ while (!cond() && Date.now() < until) await sleep(100);
+ expect(cond()).toBe(true);
+ };
+
+ const seed = async (): Promise => {
+ await mc.db(DB).dropDatabase();
+ const base = Date.now() - 30 * 86_400_000;
+ for (const coll of COLLS) {
+ await mc.db(DB).collection(coll).insertMany(Array.from({ length: DOCS }, (_, i) => {
+ const t = base + i * 60_000;
+ return { _id: `${coll.slice(-6)}_${i}`, uid: String(i % 10), did: `d${i}`, ts: t, cd: new Date(t), sg: {}, c: 1 };
+ }) as never[]);
+ }
+ await ch.command({ query: `TRUNCATE TABLE ${DB}.drill_events` });
+ };
+
+ beforeAll(async () => {
+ mc = new MongoClient(MONGO_URI);
+ await mc.connect();
+ await mc.db(`${DB}_countly`).dropDatabase();
+ await mc.db(`${DB}_countly`).collection('apps').insertOne({ _id: APP } as never);
+ await mc.db(`${DB}_countly`).collection('events').insertOne({ _id: APP, list: EVENTS } as never);
+
+ ch = createClient({ url: CH_URL, password: CH_PASSWORD });
+ await ch.command({ query: `CREATE DATABASE IF NOT EXISTS ${DB}` });
+ await ch.command({ query: `DROP TABLE IF EXISTS ${DB}.drill_events` });
+ await ch.command({
+ query: `CREATE TABLE ${DB}.drill_events (
+ \`a\` LowCardinality(String), \`e\` LowCardinality(String), \`n\` String,
+ \`uid\` String, \`uid_canon\` Nullable(String), \`did\` String, \`lsid\` Nullable(String),
+ \`_id\` String, \`ts\` DateTime64(3), \`up\` JSON(max_dynamic_paths = 32),
+ \`custom\` Nullable(JSON(max_dynamic_paths = 0)), \`cmp\` Nullable(JSON(max_dynamic_paths = 0)),
+ \`sg\` JSON(max_dynamic_paths = 0), \`c\` UInt32, \`s\` Float64, \`dur\` Float64,
+ \`lu\` Nullable(DateTime64(3)), \`cd\` DateTime64(3) DEFAULT now64(3))
+ ENGINE = MergeTree PARTITION BY toYYYYMM(ts, 'UTC') ORDER BY (a, e, n, ts)`,
+ });
+
+ ledger = new LedgerStore(MONGO_URI, DB, logger);
+ dlqStore = new DlqStore(MONGO_URI, DB, logger);
+ staging = new StagingManager({
+ url: CH_URL, database: DB, table: 'drill_events', username: 'default', password: CH_PASSWORD, queryTimeoutMs: 60_000,
+ }, logger);
+ hashResolver = new HashResolver({ uri: MONGO_URI, countlyDb: `${DB}_countly` }, logger);
+ await ledger.connect();
+ await dlqStore.connect();
+ await staging.connect();
+ await hashResolver.build();
+ closers.push(() => ledger.close(), () => dlqStore.close(), () => staging.close(), () => hashResolver.close());
+ }, 120_000);
+
+ afterAll(async () => {
+ for (const close of closers) await close().catch(() => {});
+ await ch.command({ query: `DROP DATABASE IF EXISTS ${DB}` }).catch(() => {});
+ await ch.close();
+ await mc.db(DB).dropDatabase().catch(() => {});
+ await mc.db(`${DB}_countly`).dropDatabase().catch(() => {});
+ await mc.close();
+ }, 60_000);
+
+ it('reports the collection the run is waiting on, per collection, and clears when the index is ready', async () => {
+ await seed();
+ const { orch, reader } = await mkOrchestrator('idx-auto');
+ const gate = gateEnsureIndex(reader);
+ expect(orch.autoIndexState()).toBeNull();
+ const done = orch.run();
+
+ const seen: Array<{ collection: string; position: number | null; of: number | null }> = [];
+ for (let n = 1; n <= COLLS.length; n++) {
+ await waitFor(() => gate.entered.length === n, 30_000);
+ const state = orch.autoIndexState();
+ expect(state).not.toBeNull();
+ expect(state!.collection).toBe(gate.entered[n - 1]);
+ expect(state!.startedAtMs).toBeLessThanOrEqual(Date.now());
+ const progress = await orch.indexBuildProgress();
+ expect(progress.auto).toEqual(state);
+ expect(progress.phases).toBe(4);
+ expect(Array.isArray(progress.serverOps)).toBe(true);
+ expect(progress.serverOpsError).toBeNull();
+ seen.push({ collection: state!.collection, position: state!.position, of: state!.of });
+ gate.release();
+ }
+ expect(seen.map((s) => [s.position, s.of])).toEqual([[1, 2], [2, 2]]);
+ expect(new Set(seen.map((s) => s.collection))).toEqual(new Set(COLLS));
+
+ // top-up / sweep re-probes pass through ensureIndex again — keep releasing
+ const releaser = setInterval(() => gate.release(), 50);
+ await done;
+ clearInterval(releaser);
+ expect(orch.getStats().status).toBe('completed');
+ expect(orch.autoIndexState()).toBeNull();
+ expect((await orch.indexBuildProgress()).auto).toBeNull();
+ for (const coll of COLLS) expect(await hasCdIdIndex(mc, coll)).toBe(true);
+ }, 120_000);
+
+ it('sets the state around ensureIndex even when the index is already listed', async () => {
+ await seed();
+ for (const coll of COLLS) await mc.db(DB).collection(coll).createIndex({ cd: 1, _id: 1 });
+ const { orch, reader } = await mkOrchestrator('idx-listed');
+ const gate = gateEnsureIndex(reader);
+ const done = orch.run();
+ await waitFor(() => gate.entered.length === 1, 30_000);
+ expect(orch.autoIndexState()).toMatchObject({ collection: gate.entered[0], position: 1, of: 2 });
+ const releaser = setInterval(() => gate.release(), 50);
+ await done;
+ clearInterval(releaser);
+ expect(orch.getStats().status).toBe('completed');
+ expect(orch.autoIndexState()).toBeNull();
+ }, 120_000);
+
+ it('builds missing indexes from the button and reports completion', async () => {
+ await seed();
+ const { orch } = await mkOrchestrator('idx-button');
+ const started = await orch.startIndexBuilds();
+ expect(started).toEqual({ started: true, missing: COLLS.length, inProgress: 0 });
+ const until = Date.now() + 30_000;
+ let progress = await orch.indexBuildProgress();
+ while (progress.running && Date.now() < until) { await sleep(100); progress = await orch.indexBuildProgress(); }
+ expect(progress).toMatchObject({ running: false, total: COLLS.length, error: null, current: null, auto: null });
+ expect(new Set(progress.done as string[])).toEqual(new Set(COLLS));
+ for (const coll of COLLS) expect(await hasCdIdIndex(mc, coll)).toBe(true);
+
+ // everything indexed, nothing in flight → nothing to do
+ expect(await orch.startIndexBuilds()).toEqual({ started: false, missing: 0, inProgress: 0 });
+ }, 120_000);
+});
diff --git a/tests/unit/fixtures/currentop-index-build.json b/tests/unit/fixtures/currentop-index-build.json
new file mode 100644
index 0000000..a5f3c6f
--- /dev/null
+++ b/tests/unit/fixtures/currentop-index-build.json
@@ -0,0 +1,358 @@
+{
+ "_note": "Real $currentOp entries captured on MongoDB 8.0.34 (2-member replica set rs8) during createIndex({cd:1,_id:1}) on a 1.5M-doc collection in db probe. primary.* sampled on the primary, secondary.* on the secondary (note: no command.$db there). lsid removed.",
+ "primary.waiter": {
+ "type": "op",
+ "desc": "conn40",
+ "appName": "mongosh 2.13.0",
+ "active": true,
+ "isFromUserConnection": true,
+ "opid": 78852,
+ "secs_running": 0,
+ "microsecs_running": 60098,
+ "op": "command",
+ "ns": "probe.drill_events_probe",
+ "redacted": false,
+ "command": {
+ "createIndexes": "drill_events_probe",
+ "indexes": [
+ {
+ "name": "cd_1__id_1",
+ "key": {
+ "cd": 1,
+ "_id": 1
+ }
+ }
+ ],
+ "$clusterTime": {
+ "clusterTime": {
+ "$timestamp": {
+ "t": 1792704236,
+ "i": 100
+ }
+ },
+ "signature": {
+ "hash": {
+ "$binary": {
+ "base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
+ "subType": "00"
+ }
+ },
+ "keyId": 0
+ }
+ },
+ "$readPreference": {
+ "mode": "primaryPreferred"
+ },
+ "$db": "probe"
+ },
+ "numYields": 0,
+ "numInterruptChecks": 17,
+ "currentQueue": null
+ },
+ "primary.scan": {
+ "type": "op",
+ "desc": "IndexBuildsCoordinatorMongod-0",
+ "active": true,
+ "isFromUserConnection": false,
+ "opid": 81920,
+ "secs_running": 0,
+ "microsecs_running": 306243,
+ "op": "command",
+ "ns": "probe.drill_events_probe",
+ "redacted": false,
+ "command": {
+ "createIndexes": "drill_events_probe",
+ "indexes": [
+ {
+ "v": 2,
+ "key": {
+ "cd": 1,
+ "_id": 1
+ },
+ "name": "cd_1__id_1"
+ }
+ ],
+ "$clusterTime": {
+ "clusterTime": {
+ "$timestamp": {
+ "t": 1792704236,
+ "i": 100
+ }
+ },
+ "signature": {
+ "hash": {
+ "$binary": {
+ "base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
+ "subType": "00"
+ }
+ },
+ "keyId": 0
+ }
+ },
+ "$readPreference": {
+ "mode": "primaryPreferred"
+ },
+ "$db": "probe"
+ },
+ "msg": "Index Build: scanning collection Index Build: scanning collection: 101951/1500000 6%",
+ "progress": {
+ "done": 101951,
+ "total": 1500000
+ },
+ "numYields": 13,
+ "numInterruptChecks": 102034,
+ "currentQueue": null
+ },
+ "primary.scanNoProgress": {
+ "type": "op",
+ "desc": "IndexBuildsCoordinatorMongod-0",
+ "active": true,
+ "isFromUserConnection": false,
+ "opid": 81920,
+ "secs_running": 3,
+ "microsecs_running": 3636956,
+ "op": "command",
+ "ns": "probe.drill_events_probe",
+ "redacted": false,
+ "command": {
+ "createIndexes": "drill_events_probe",
+ "indexes": [
+ {
+ "v": 2,
+ "key": {
+ "cd": 1,
+ "_id": 1
+ },
+ "name": "cd_1__id_1"
+ }
+ ],
+ "$clusterTime": {
+ "clusterTime": {
+ "$timestamp": {
+ "t": 1792704236,
+ "i": 100
+ }
+ },
+ "signature": {
+ "hash": {
+ "$binary": {
+ "base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
+ "subType": "00"
+ }
+ },
+ "keyId": 0
+ }
+ },
+ "$readPreference": {
+ "mode": "primaryPreferred"
+ },
+ "$db": "probe"
+ },
+ "msg": "Index Build: scanning collection",
+ "numYields": 171,
+ "numInterruptChecks": 1500873,
+ "currentQueue": null
+ },
+ "primary.sorter": {
+ "type": "op",
+ "desc": "IndexBuildsCoordinatorMongod-0",
+ "active": true,
+ "isFromUserConnection": false,
+ "opid": 81920,
+ "secs_running": 6,
+ "microsecs_running": 6191279,
+ "op": "command",
+ "ns": "probe.drill_events_probe",
+ "redacted": false,
+ "command": {
+ "createIndexes": "drill_events_probe",
+ "indexes": [
+ {
+ "v": 2,
+ "key": {
+ "cd": 1,
+ "_id": 1
+ },
+ "name": "cd_1__id_1"
+ }
+ ],
+ "$clusterTime": {
+ "clusterTime": {
+ "$timestamp": {
+ "t": 1792704236,
+ "i": 100
+ }
+ },
+ "signature": {
+ "hash": {
+ "$binary": {
+ "base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
+ "subType": "00"
+ }
+ },
+ "keyId": 0
+ }
+ },
+ "$readPreference": {
+ "mode": "primaryPreferred"
+ },
+ "$db": "probe"
+ },
+ "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 38606/1500000 2%",
+ "progress": {
+ "done": 38606,
+ "total": 1500000
+ },
+ "numYields": 209,
+ "numInterruptChecks": 1539632,
+ "currentQueue": null
+ },
+ "primary.sorterNoProgress": {
+ "type": "op",
+ "desc": "IndexBuildsCoordinatorMongod-0",
+ "active": true,
+ "isFromUserConnection": false,
+ "opid": 81920,
+ "secs_running": 7,
+ "microsecs_running": 7986437,
+ "op": "command",
+ "ns": "probe.drill_events_probe",
+ "redacted": false,
+ "command": {
+ "createIndexes": "drill_events_probe",
+ "indexes": [
+ {
+ "v": 2,
+ "key": {
+ "cd": 1,
+ "_id": 1
+ },
+ "name": "cd_1__id_1"
+ }
+ ],
+ "$clusterTime": {
+ "clusterTime": {
+ "$timestamp": {
+ "t": 1792704236,
+ "i": 100
+ }
+ },
+ "signature": {
+ "hash": {
+ "$binary": {
+ "base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
+ "subType": "00"
+ }
+ },
+ "keyId": 0
+ }
+ },
+ "$readPreference": {
+ "mode": "primaryPreferred"
+ },
+ "$db": "probe"
+ },
+ "msg": "Index Build: inserting keys from external sorter into index",
+ "numYields": 1671,
+ "numInterruptChecks": 3006873,
+ "currentQueue": null
+ },
+ "secondary.scan": {
+ "type": "op",
+ "desc": "IndexBuildsCoordinatorMongod-0",
+ "active": true,
+ "isFromUserConnection": false,
+ "opid": 63488,
+ "secs_running": 0,
+ "microsecs_running": 68739,
+ "op": "command",
+ "ns": "probe.drill_events_probe",
+ "redacted": false,
+ "command": {
+ "createIndexes": "drill_events_probe",
+ "indexes": [
+ {
+ "v": 2,
+ "key": {
+ "cd": 1,
+ "_id": 1
+ },
+ "name": "cd_1__id_1"
+ }
+ ]
+ },
+ "queryFramework": "classic",
+ "msg": "Index Build: scanning collection Index Build: scanning collection: 10561/1500000 0%",
+ "progress": {
+ "done": 10561,
+ "total": 1500000
+ },
+ "numYields": 1,
+ "numInterruptChecks": 10585,
+ "currentQueue": null
+ },
+ "secondary.scanNoProgress": {
+ "type": "op",
+ "desc": "IndexBuildsCoordinatorMongod-0",
+ "active": true,
+ "isFromUserConnection": false,
+ "opid": 63488,
+ "secs_running": 3,
+ "microsecs_running": 3709206,
+ "op": "command",
+ "ns": "probe.drill_events_probe",
+ "redacted": false,
+ "command": {
+ "createIndexes": "drill_events_probe",
+ "indexes": [
+ {
+ "v": 2,
+ "key": {
+ "cd": 1,
+ "_id": 1
+ },
+ "name": "cd_1__id_1"
+ }
+ ]
+ },
+ "queryFramework": "classic",
+ "msg": "Index Build: scanning collection",
+ "numYields": 171,
+ "numInterruptChecks": 1500874,
+ "currentQueue": null
+ },
+ "secondary.sorter": {
+ "type": "op",
+ "desc": "IndexBuildsCoordinatorMongod-0",
+ "active": true,
+ "isFromUserConnection": false,
+ "opid": 63488,
+ "secs_running": 6,
+ "microsecs_running": 6010756,
+ "op": "command",
+ "ns": "probe.drill_events_probe",
+ "redacted": false,
+ "command": {
+ "createIndexes": "drill_events_probe",
+ "indexes": [
+ {
+ "v": 2,
+ "key": {
+ "cd": 1,
+ "_id": 1
+ },
+ "name": "cd_1__id_1"
+ }
+ ]
+ },
+ "queryFramework": "classic",
+ "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 152844/1500000 10%",
+ "progress": {
+ "done": 152844,
+ "total": 1500000
+ },
+ "numYields": 323,
+ "numInterruptChecks": 1654327,
+ "currentQueue": null
+ }
+}
diff --git a/tests/unit/fixtures/streams/currentop-m8-primary.json b/tests/unit/fixtures/streams/currentop-m8-primary.json
new file mode 100644
index 0000000..d581855
--- /dev/null
+++ b/tests/unit/fixtures/streams/currentop-m8-primary.json
@@ -0,0 +1 @@
+[[{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 106638/1500000 7%", "progress": {"done": 106638, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 222359/1500000 14%", "progress": {"done": 222359, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 333785/1500000 22%", "progress": {"done": 333785, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 452404/1500000 30%", "progress": {"done": 452404, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 553820/1500000 36%", "progress": {"done": 553820, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 674991/1500000 44%", "progress": {"done": 674991, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 793925/1500000 52%", "progress": {"done": 793925, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 904826/1500000 60%", "progress": {"done": 904826, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 1024468/1500000 68%", "progress": {"done": 1024468, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 1093824/1500000 72%", "progress": {"done": 1093824, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 1201910/1500000 80%", "progress": {"done": 1201910, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 1289792/1500000 85%", "progress": {"done": 1289792, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 1402981/1500000 93%", "progress": {"done": 1402981, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 115999/1500000 7%", "progress": {"done": 115999, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 342244/1500000 22%", "progress": {"done": 342244, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 543399/1500000 36%", "progress": {"done": 543399, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 765789/1500000 51%", "progress": {"done": 765789, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 985412/1500000 65%", "progress": {"done": 985412, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 1219997/1500000 81%", "progress": {"done": 1219997, "total": 1500000}}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index"}, {"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792704472, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "$readPreference": {"mode": "primaryPreferred"}, "$db": "probe"}}]]
\ No newline at end of file
diff --git a/tests/unit/fixtures/streams/currentop-m8-secondary.json b/tests/unit/fixtures/streams/currentop-m8-secondary.json
new file mode 100644
index 0000000..f4a3390
--- /dev/null
+++ b/tests/unit/fixtures/streams/currentop-m8-secondary.json
@@ -0,0 +1 @@
+[[{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 29054/1500000 1%", "progress": {"done": 29054, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 152995/1500000 10%", "progress": {"done": 152995, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 267822/1500000 17%", "progress": {"done": 267822, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 402169/1500000 26%", "progress": {"done": 402169, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 524288/1500000 34%", "progress": {"done": 524288, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 649782/1500000 43%", "progress": {"done": 649782, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 766780/1500000 51%", "progress": {"done": 766780, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 883492/1500000 58%", "progress": {"done": 883492, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 1013184/1500000 67%", "progress": {"done": 1013184, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 1104956/1500000 73%", "progress": {"done": 1104956, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 1234085/1500000 82%", "progress": {"done": 1234085, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 1320650/1500000 88%", "progress": {"done": 1320650, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection Index Build: scanning collection: 1456408/1500000 97%", "progress": {"done": 1456408, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection"}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection"}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection"}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection"}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection"}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection"}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection"}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection"}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection"}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: scanning collection"}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 154041/1500000 10%", "progress": {"done": 154041, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 378094/1500000 25%", "progress": {"done": 378094, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 570758/1500000 38%", "progress": {"done": 570758, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 793528/1500000 52%", "progress": {"done": 793528, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 1014590/1500000 67%", "progress": {"done": 1014590, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 1048416/1500000 69%", "progress": {"done": 1048416, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 1099438/1500000 73%", "progress": {"done": 1099438, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 1248624/1500000 83%", "progress": {"done": 1248624, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 1290341/1500000 86%", "progress": {"done": 1290341, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 1423717/1500000 94%", "progress": {"done": 1423717, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 1466500/1500000 97%", "progress": {"done": 1466500, "total": 1500000}}], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: inserting keys from external sorter into index"}], [], [{"ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}]}, "msg": "Index Build: draining writes received during build"}]]
\ No newline at end of file
diff --git a/tests/unit/fixtures/streams/currentop-m8-sharded-mongos.json b/tests/unit/fixtures/streams/currentop-m8-sharded-mongos.json
new file mode 100644
index 0000000..f78dc68
--- /dev/null
+++ b/tests/unit/fixtures/streams/currentop-m8-sharded-mongos.json
@@ -0,0 +1 @@
+[[{"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 86363/499456 17%", "progress": {"done": 86363, "total": 499456}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 86998/500544 17%", "progress": {"done": 86998, "total": 500544}}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}], [{"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 193878/499456 38%", "progress": {"done": 193878, "total": 499456}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 186982/500544 37%", "progress": {"done": 186982, "total": 500544}}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}], [{"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 305165/500544 60%", "progress": {"done": 305165, "total": 500544}}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 307919/499456 61%", "progress": {"done": 307919, "total": 499456}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}], [{"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 436144/499456 87%", "progress": {"done": 436144, "total": 499456}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection Index Build: scanning collection: 448003/500544 89%", "progress": {"done": 448003, "total": 500544}}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}], [{"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}], [{"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}], [{"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 39959/500544 7%", "progress": {"done": 39959, "total": 500544}}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: scanning collection"}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}], [{"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 309988/500544 61%", "progress": {"done": 309988, "total": 500544}}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 223410/499456 44%", "progress": {"done": 223410, "total": 499456}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}], [{"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index"}, {"shard": "s2", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 0}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"v": 2, "key": {"cd": 1, "_id": 1}, "name": "cd_1__id_1"}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}, "msg": "Index Build: inserting keys from external sorter into index Index Build: inserting keys from external sorter into index: 455170/499456 91%", "progress": {"done": 455170, "total": 499456}}, {"shard": "s1", "ns": "probe.drill_events_probe", "command": {"createIndexes": "drill_events_probe", "indexes": [{"name": "cd_1__id_1", "key": {"cd": 1, "_id": 1}}], "readConcern": {"level": "local", "provenance": "implicitDefault"}, "writeConcern": {"w": "majority", "wtimeout": 0, "provenance": "implicitDefault"}, "shardVersion": {"e": {"$oid": "6ada81aa9629da61661c3431"}, "t": {"$timestamp": {"t": 1792704938, "i": 64}}, "v": {"$timestamp": {"t": 1, "i": 1}}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1792705254, "i": 1}}}, "$configTime": {"$timestamp": {"t": 1792705253, "i": 1}}, "$topologyTime": {"$timestamp": {"t": 1792704938, "i": 28}}, "$client": {"application": {"name": "mongosh 2.13.0"}, "driver": {"name": "nodejs|mongosh", "version": "7.5.0|2.13.0"}, "platform": "Node.js v24.21.0, LE", "os": {"name": "linux", "architecture": "x64", "version": "3.10.0-327.22.2.el7.x86_64", "type": "Linux"}, "env": {"container": {"runtime": "docker"}}, "mongos": {"host": "f74b34553b11:27017", "client": "127.0.0.1:49852", "version": "8.0.34"}}, "mayBypassWriteBlocking": false, "$db": "probe"}}]]
\ No newline at end of file
diff --git a/tests/unit/index-build-ops.test.ts b/tests/unit/index-build-ops.test.ts
new file mode 100644
index 0000000..baacd0f
--- /dev/null
+++ b/tests/unit/index-build-ops.test.ts
@@ -0,0 +1,232 @@
+/**
+ * $currentOp → index-build progress, against REAL captures only:
+ *
+ * fixtures/currentop-index-build.json MongoDB 8.0.34 replica set, one op per shape,
+ * primary + secondary
+ * fixtures/streams/*.json every $currentOp sample (250ms apart, the
+ * service's own projection + readConcern) over
+ * one whole build: 8.0 primary, 8.0 secondary,
+ * 8.0 2-shard cluster via mongos
+ *
+ * Pinned here:
+ * - the builder thread's progress wins over the client op waiting on it
+ * - the phase travels with the percentage (it restarts at 0% in each phase)
+ * - secondaries (no command.$db) are matched through ns
+ * - builds of other indexes, other dbs and other commands are ignored
+ * - behind mongos the least advanced shard is reported, with the shard count
+ * - replayed over a whole build: one entry per sample, phases never go
+ * backwards, the percentage never drops within a phase
+ */
+import { describe, it, expect } from 'vitest';
+import { readFileSync } from 'node:fs';
+
+import { parseIndexBuildOps, INDEX_BUILD_PHASES, type IndexBuildOp } from '../../src/source/index-build-ops.ts';
+
+type Op = Record;
+const load = (rel: string): T => JSON.parse(readFileSync(new URL(rel, import.meta.url), 'utf8')) as T;
+const m8 = load>('./fixtures/currentop-index-build.json');
+// the primary's ops, one per shape
+const p = {
+ waiter: m8['primary.waiter'], scan: m8['primary.scan'], scanNoProgress: m8['primary.scanNoProgress'],
+ sorter: m8['primary.sorter'], sorterNoProgress: m8['primary.sorterNoProgress'],
+};
+const STREAMS: Record = {
+ 'MongoDB 8.0 replica-set primary': load('./fixtures/streams/currentop-m8-primary.json'),
+ 'MongoDB 8.0 replica-set secondary': load('./fixtures/streams/currentop-m8-secondary.json'),
+ 'MongoDB 8.0 sharded (2 shards, via mongos)': load('./fixtures/streams/currentop-m8-sharded-mongos.json'),
+};
+const clone = (op: Op): Op => structuredClone(op);
+const COLL = 'drill_events_probe';
+const DB = 'probe';
+
+describe('parseIndexBuildOps — MongoDB 8.0 primary captures', () => {
+ it('reports the scanning phase from the builder, not the waiting client', () => {
+ expect(parseIndexBuildOps([p.waiter, p.scan], DB)).toEqual([{
+ collection: COLL, phase: 1, phaseLabel: 'scanning documents',
+ done: 101951, total: 1500000, pct: 7, msg: p.scan.msg, shard: null, shards: 0,
+ }]);
+ // order of the two ops does not matter
+ expect(parseIndexBuildOps([p.scan, p.waiter], DB)[0].pct).toBe(7);
+ });
+
+ it('reports the key-writing step with its own percentage', () => {
+ expect(parseIndexBuildOps([p.waiter, p.sorter], DB)[0])
+ .toMatchObject({ phase: 3, phaseLabel: 'writing index keys', done: 38606, total: 1500000, pct: 3 });
+ });
+
+ it('"scanning" without counters is the sorting step; key writing without counters stays step 3', () => {
+ expect(parseIndexBuildOps([p.scanNoProgress], DB)[0])
+ .toMatchObject({ phase: 2, phaseLabel: 'sorting index keys (scan complete)', done: null, total: null, pct: null });
+ expect(parseIndexBuildOps([p.sorterNoProgress], DB)[0]).toMatchObject({ phase: 3, pct: null });
+ });
+
+ it('falls back to the client op when no builder is visible', () => {
+ expect(parseIndexBuildOps([p.waiter], DB)).toEqual([{
+ collection: COLL, phase: null, phaseLabel: 'in progress', done: null, total: null, pct: null, msg: '', shard: null, shards: 0,
+ }]);
+ });
+
+ it('labels the draining phase and keeps unknown phases in the server\'s words', () => {
+ const drain = clone(p.scan);
+ drain.msg = 'Index Build: draining writes received during build';
+ delete drain.progress;
+ expect(parseIndexBuildOps([drain], DB)[0])
+ .toMatchObject({ phase: 4, phaseLabel: 'applying writes made during the build', pct: null });
+ const future = clone(p.scan);
+ future.msg = 'Index Build: committing the index: 5/10 50%';
+ delete future.progress;
+ expect(parseIndexBuildOps([future], DB)[0])
+ .toMatchObject({ phase: null, phaseLabel: 'committing the index', pct: null });
+ });
+
+ it('ignores other databases, other indexes and non-index ops', () => {
+ const otherDb = clone(p.scan);
+ (otherDb.command as Op).$db = 'countly_migration';
+ const otherIndex = clone(p.scan);
+ (otherIndex.command as Op).indexes = [{ v: 2, key: { run_id: 1, status: 1 }, name: 'run_id_1_status_1' }];
+ const reversed = clone(p.scan);
+ (reversed.command as Op).indexes = [{ v: 2, key: { _id: 1, cd: 1 }, name: '_id_1_cd_1' }];
+ const wider = clone(p.scan);
+ (wider.command as Op).indexes = [{ v: 2, key: { cd: 1, _id: 1, uid: 1 }, name: 'cd_1__id_1_uid_1' }];
+ const find: Op = { ns: `${DB}.${COLL}`, command: { find: COLL, $db: DB } };
+ const noCommand: Op = { ns: `${DB}.${COLL}`, msg: 'Index Build: scanning collection' };
+ expect(parseIndexBuildOps([otherDb, otherIndex, reversed, wider, find, noCommand], DB)).toEqual([]);
+ });
+
+ it('finds the {cd,_id} spec inside a multi-index createIndexes', () => {
+ const multi = clone(p.scan);
+ (multi.command as Op).indexes = [{ v: 2, key: { uid: 1 }, name: 'uid_1' }, { v: 2, key: { cd: 1, _id: 1 }, name: 'cd_1__id_1' }];
+ expect(parseIndexBuildOps([multi], DB)).toHaveLength(1);
+ });
+
+ it('caps a percentage the server overshoots and ignores a zero total', () => {
+ const over = clone(p.scan);
+ over.progress = { done: 1_600_000, total: 1_500_000 };
+ expect(parseIndexBuildOps([over], DB)[0].pct).toBe(100);
+ const zero = clone(p.scan);
+ zero.progress = { done: 0, total: 0 };
+ expect(parseIndexBuildOps([zero], DB)[0]).toMatchObject({ pct: null, total: null, phase: 1 });
+ });
+
+ it('returns one entry per collection and nothing for an empty op list', () => {
+ const second = clone(p.sorter);
+ (second.command as Op).createIndexes = 'drill_events_other';
+ const out = parseIndexBuildOps([p.waiter, p.scan, second], DB);
+ expect(out.map((o) => [o.collection, o.phase])).toEqual([[COLL, 1], ['drill_events_other', 3]]);
+ expect(parseIndexBuildOps([], DB)).toEqual([]);
+ });
+});
+
+describe('parseIndexBuildOps — MongoDB 8.0 replica set', () => {
+ it('primary: every shape', () => {
+ expect(parseIndexBuildOps([m8['primary.waiter'], m8['primary.scan']], DB)[0])
+ .toMatchObject({ collection: COLL, phase: 1, total: 1_500_000, shards: 0 });
+ expect(parseIndexBuildOps([m8['primary.scanNoProgress']], DB)[0]).toMatchObject({ phase: 2, pct: null });
+ expect(parseIndexBuildOps([m8['primary.waiter'], m8['primary.sorter']], DB)[0])
+ .toMatchObject({ phase: 3, total: 1_500_000 });
+ expect(parseIndexBuildOps([m8['primary.sorterNoProgress']], DB)[0]).toMatchObject({ phase: 3, pct: null });
+ });
+
+ it('secondary: the builder op has no command.$db and is matched through ns', () => {
+ const op = m8['secondary.scan'];
+ expect((op.command as Op).$db).toBeUndefined();
+ expect(parseIndexBuildOps([op], DB)[0]).toMatchObject({ collection: COLL, phase: 1, total: 1_500_000 });
+ expect(parseIndexBuildOps([op], 'countly_drill')).toEqual([]);
+ expect(parseIndexBuildOps([m8['secondary.scanNoProgress']], DB)[0]).toMatchObject({ phase: 2 });
+ expect(parseIndexBuildOps([m8['secondary.sorter']], DB)[0]).toMatchObject({ phase: 3 });
+ });
+});
+
+describe('parseIndexBuildOps — sharded cluster via mongos (real 2-shard capture)', () => {
+ const stream = STREAMS['MongoDB 8.0 sharded (2 shards, via mongos)'];
+
+ it('every op carries its shard and both shards build', () => {
+ const shards = new Set(stream.flat().map((o) => o.shard));
+ expect(shards).toEqual(new Set(['s1', 's2']));
+ });
+
+ it('reports the least advanced shard and the shard count, sample by sample', () => {
+ for (const sample of stream) {
+ const [entry] = parseIndexBuildOps(sample, DB);
+ const builders = sample
+ .filter((o) => o.progress !== undefined)
+ .map((o) => parseIndexBuildOps([o], DB)[0]);
+ expect(entry.shards).toBe(new Set(sample.map((o) => o.shard)).size);
+ if (builders.length === 0) continue;
+ const minPhase = Math.min(...builders.map((b) => b.phase ?? 0));
+ const inPhase = builders.filter((b) => (b.phase ?? 0) === minPhase);
+ if (entry.pct !== null) {
+ expect(entry.phase).toBe(minPhase);
+ expect(entry.pct).toBe(Math.min(...inPhase.map((b) => b.pct ?? 101)));
+ expect(entry.total).toBeLessThan(1_000_000); // per-shard counters, not the collection total
+ }
+ }
+ });
+
+ it('a shard momentarily without counters never hides one that has them', () => {
+ const withCounters = clone(m8['primary.sorter']);
+ withCounters.shard = 's1';
+ withCounters.progress = { done: 455_170, total: 499_456 };
+ const noCounters = clone(m8['primary.sorterNoProgress']);
+ noCounters.shard = 's2';
+ for (const ops of [[withCounters, noCounters], [noCounters, withCounters]]) {
+ expect(parseIndexBuildOps(ops, DB)[0]).toMatchObject({ shard: 's1', pct: 91, shards: 2 });
+ }
+ });
+});
+
+describe.each(Object.entries(STREAMS))('replaying a whole build — %s', (_name, stream) => {
+ const parsed = stream.map((sample) => parseIndexBuildOps(sample, DB));
+ const entries: IndexBuildOp[] = parsed.map((out) => out[0]).filter(Boolean);
+
+ it('one entry per sample (one collection building)', () => {
+ for (const out of parsed) expect(out.length).toBeLessThanOrEqual(1);
+ });
+
+ it('captured a real build', () => {
+ expect(stream.length).toBeGreaterThanOrEqual(5);
+ expect(entries.length).toBeGreaterThanOrEqual(5);
+ });
+
+ it('sees both counted steps with counters', () => {
+ for (const phase of [1, 3]) {
+ expect(entries.some((e) => e.phase === phase && e.pct !== null)).toBe(true);
+ }
+ });
+
+ it('passes through the sorting step, only after the scan counters and before key writing', () => {
+ const firstSort = entries.findIndex((e) => e.phase === 2);
+ expect(firstSort).toBeGreaterThan(0);
+ expect(entries.slice(0, firstSort).some((e) => e.phase === 1 && e.pct !== null)).toBe(true);
+ expect(entries.slice(0, firstSort).some((e) => (e.phase ?? 0) > 2)).toBe(false);
+ // the scan was (near) complete when sorting started
+ const lastScan = entries.slice(0, firstSort).filter((e) => e.phase === 1 && e.pct !== null).pop()!;
+ expect(lastScan.pct).toBeGreaterThanOrEqual(70);
+ });
+
+ it('never goes backwards: phase non-decreasing, percentage non-decreasing within a phase', () => {
+ let last: IndexBuildOp | null = null;
+ for (const e of entries) {
+ if (e.phase === null) continue;
+ if (last && last.phase !== null) {
+ expect(e.phase).toBeGreaterThanOrEqual(last.phase);
+ if (e.phase === last.phase && e.pct !== null && last.pct !== null) {
+ expect(e.pct).toBeGreaterThanOrEqual(last.pct);
+ }
+ }
+ if (e.pct !== null || !last || e.phase !== last.phase) last = e;
+ }
+ });
+
+ it('every entry is the drill collection with a sane percentage', () => {
+ for (const e of entries) {
+ expect(e.collection).toBe(COLL);
+ if (e.pct !== null) {
+ expect(e.pct).toBeGreaterThanOrEqual(0);
+ expect(e.pct).toBeLessThanOrEqual(100);
+ expect(e.done).not.toBeNull();
+ }
+ if (e.phase !== null) expect(e.phase).toBeLessThanOrEqual(INDEX_BUILD_PHASES);
+ }
+ });
+});
diff --git a/tests/unit/orchestrator-index-progress.test.ts b/tests/unit/orchestrator-index-progress.test.ts
new file mode 100644
index 0000000..4ab5e8e
--- /dev/null
+++ b/tests/unit/orchestrator-index-progress.test.ts
@@ -0,0 +1,213 @@
+/**
+ * ChunkOrchestrator index-build bookkeeping against a fake MongoDB (no
+ * database needed). Pinned here:
+ *
+ * - $currentOp runs with readConcern 'local' and projects `shard`; any
+ * failure is reported as serverOpsError, never swallowed into "no builds"
+ * - startIndexBuilds builds unlisted indexes AND joins builds already in
+ * flight (listed as present, but not ready), reporting how many it joined
+ * - a failing build stops the queue and is reported
+ * - mapping clears the "waiting on index" state when ensureIndex fails, and
+ * names the collection while it waits
+ */
+import { describe, it, expect, vi } from 'vitest';
+import pino from 'pino';
+import { readFileSync } from 'node:fs';
+
+import { ChunkOrchestrator, type ChunkOrchestratorDeps } from '../../src/runtime/chunk-orchestrator.ts';
+
+type Op = Record;
+const m8 = JSON.parse(readFileSync(new URL('./fixtures/currentop-index-build.json', import.meta.url), 'utf8')) as Record;
+const building = [m8['primary.waiter'], m8['primary.scan']]; // MongoDB 8.0 primary, scan at 7%
+const DB = 'probe';
+const PREFIX = 'drill_events';
+const sleep = (ms: number): Promise => new Promise((r) => setTimeout(r, ms));
+
+interface FakeColl { indexed: boolean; createIndex: (spec: unknown) => Promise }
+
+function fakeMongo(opts: {
+ collections: Record;
+ currentOp?: () => Promise;
+}) {
+ const aggregateCalls: Array<{ pipeline: Op[]; options: Op | undefined }> = [];
+ const db = {
+ databaseName: DB,
+ listCollections: () => ({ toArray: async () => Object.keys(opts.collections).map((name) => ({ name })) }),
+ collection: (name: string) => ({
+ indexes: async () => [{ name: '_id_', key: { _id: 1 } }, ...(opts.collections[name].indexed ? [{ name: 'cd_1__id_1', key: { cd: 1, _id: 1 } }] : [])],
+ createIndex: (spec: unknown) => opts.collections[name].createIndex(spec),
+ }),
+ client: {
+ db: (name: string) => {
+ expect(name).toBe('admin');
+ return {
+ aggregate: (pipeline: Op[], options?: Op) => {
+ aggregateCalls.push({ pipeline, options });
+ return { toArray: () => (opts.currentOp ?? (async () => []))() };
+ },
+ };
+ },
+ },
+ };
+ return { db, aggregateCalls };
+}
+
+function mkOrchestrator(db: unknown, reader: Partial> = {}): ChunkOrchestrator {
+ const deps = {
+ config: {
+ ledger: { dryRun: false, runId: 'unit', cdUpperBoundMs: null },
+ worker: { podId: 'unit-pod' },
+ source: { collectionPrefix: PREFIX },
+ },
+ logger: pino({ level: 'silent' }),
+ mongoReader: { getDatabase: () => db, ...reader },
+ hashResolver: { resolveCollectionName: () => null },
+ } as unknown as ChunkOrchestratorDeps;
+ return new ChunkOrchestrator(deps);
+}
+
+const waitUntil = async (cond: () => Promise | boolean, ms = 2_000): Promise => {
+ const until = Date.now() + ms;
+ while (!(await cond())) {
+ if (Date.now() > until) throw new Error('condition not met in time');
+ await sleep(5);
+ }
+};
+
+describe('index-build progress — $currentOp query', () => {
+ it('pins readConcern local and projects the shard field', async () => {
+ const { db, aggregateCalls } = fakeMongo({ collections: {}, currentOp: async () => building });
+ const progress = await mkOrchestrator(db).indexBuildProgress();
+ expect(aggregateCalls).toHaveLength(1);
+ expect(aggregateCalls[0].options).toEqual({ readConcern: { level: 'local' } });
+ expect(aggregateCalls[0].pipeline[0]).toEqual({ $currentOp: { allUsers: true } });
+ expect(aggregateCalls[0].pipeline[2]).toEqual({ $project: { ns: 1, command: 1, progress: 1, msg: 1, shard: 1 } });
+ expect(progress).toMatchObject({ serverOpsError: null, phases: 4, auto: null, running: false });
+ expect(progress.serverOps).toEqual([expect.objectContaining({ collection: 'drill_events_probe', phase: 1, pct: 7 })]);
+ });
+
+ it('reports a failing $currentOp instead of pretending nothing is building', async () => {
+ const { db } = fakeMongo({
+ collections: {},
+ currentOp: async () => { throw new Error('not authorized on admin to execute command { aggregate: 1 }'); },
+ });
+ const progress = await mkOrchestrator(db).indexBuildProgress();
+ expect(progress.serverOps).toEqual([]);
+ expect(progress.serverOpsError).toBe('not authorized on admin to execute command { aggregate: 1 }');
+ });
+});
+
+describe('index-build progress — Build missing indexes button', () => {
+ it('builds unlisted indexes, joins the in-flight one, skips the ready one', async () => {
+ const built: string[] = [];
+ const mk = (name: string, indexed: boolean): FakeColl => ({
+ indexed,
+ createIndex: async (spec) => { expect(spec).toEqual({ cd: 1, _id: 1 }); await sleep(20); built.push(name); return 'cd_1__id_1'; },
+ });
+ // drill_events_probe: listed (in-flight build, $currentOp shows it) → joined
+ // drill_events_ready: listed, nothing in flight → skipped
+ // drill_events_new: not listed → built
+ const collections = {
+ drill_events_new: mk('drill_events_new', false),
+ drill_events_probe: mk('drill_events_probe', true),
+ drill_events_ready: mk('drill_events_ready', true),
+ };
+ const { db } = fakeMongo({ collections, currentOp: async () => building });
+ const orch = mkOrchestrator(db);
+
+ expect(await orch.startIndexBuilds()).toEqual({ started: true, missing: 2, inProgress: 1 });
+ // a second click while running does not start a second queue
+ expect((await orch.startIndexBuilds()).started).toBe(false);
+ await waitUntil(async () => (await orch.indexBuildProgress()).running === false);
+ const progress = await orch.indexBuildProgress();
+ expect(progress).toMatchObject({ running: false, total: 2, error: null, current: null });
+ expect(progress.done).toEqual(['drill_events_new', 'drill_events_probe']);
+ expect(built).toEqual(['drill_events_new', 'drill_events_probe']);
+ });
+
+ it('reports "nothing to do" only when nothing is unlisted and nothing is in flight', async () => {
+ const coll = (): FakeColl => ({ indexed: true, createIndex: vi.fn() });
+ const { db } = fakeMongo({ collections: { drill_events_a: coll(), drill_events_b: coll() } });
+ expect(await mkOrchestrator(db).startIndexBuilds()).toEqual({ started: false, missing: 0, inProgress: 0 });
+ });
+
+ it('still builds unlisted indexes when $currentOp is not permitted', async () => {
+ const { db } = fakeMongo({
+ collections: { drill_events_a: { indexed: false, createIndex: async () => 'cd_1__id_1' } },
+ currentOp: async () => { throw new Error('not authorized'); },
+ });
+ const orch = mkOrchestrator(db);
+ expect(await orch.startIndexBuilds()).toEqual({ started: true, missing: 1, inProgress: 0 });
+ await waitUntil(async () => (await orch.indexBuildProgress()).running === false);
+ expect(await orch.indexBuildProgress()).toMatchObject({ done: ['drill_events_a'], error: null, serverOpsError: 'not authorized' });
+ });
+
+ it('stops the queue on a failed build and reports which one', async () => {
+ const { db } = fakeMongo({
+ collections: {
+ drill_events_a: { indexed: false, createIndex: async () => { throw new Error('disk full'); } },
+ drill_events_b: { indexed: false, createIndex: vi.fn(async () => 'cd_1__id_1') },
+ },
+ });
+ const orch = mkOrchestrator(db);
+ await orch.startIndexBuilds();
+ await waitUntil(async () => (await orch.indexBuildProgress()).running === false);
+ expect(await orch.indexBuildProgress()).toMatchObject({ running: false, done: [], error: 'drill_events_a: disk full' });
+ });
+});
+
+describe('index-build progress — mapping-time wait', () => {
+ type Mapper = { mapCollection(c: string, at?: { position: number; of: number }): Promise };
+
+ it('names the collection while ensureIndex blocks, then clears', async () => {
+ let release: () => void = () => {};
+ const { db } = fakeMongo({ collections: {} });
+ const orch = mkOrchestrator(db, {
+ switchCollection: async () => {},
+ hasRequiredIndex: async () => false,
+ ensureIndex: () => new Promise((r) => { release = r; }),
+ getLowerBound: async () => null,
+ getUpperBound: async () => null,
+ hasNullCdDocuments: async () => false,
+ });
+ const t0 = Date.now();
+ const mapping = (orch as unknown as Mapper).mapCollection('drill_events_probe', { position: 3, of: 12 });
+ await waitUntil(() => orch.autoIndexState() !== null);
+ const state = orch.autoIndexState()!;
+ expect(state).toMatchObject({ collection: 'drill_events_probe', position: 3, of: 12 });
+ expect(state.startedAtMs).toBeGreaterThanOrEqual(t0);
+ expect((await orch.indexBuildProgress()).auto).toEqual(state);
+ release();
+ expect(await mapping).toBe(0); // empty collection: nothing mapped
+ expect(orch.autoIndexState()).toBeNull();
+ });
+
+ it('clears the state when the index build fails', async () => {
+ const { db } = fakeMongo({ collections: {} });
+ const orch = mkOrchestrator(db, {
+ switchCollection: async () => {},
+ hasRequiredIndex: async () => true,
+ ensureIndex: async () => { throw new Error('index build aborted'); },
+ });
+ await expect((orch as unknown as Mapper).mapCollection('drill_events_probe')).rejects.toThrow('index build aborted');
+ expect(orch.autoIndexState()).toBeNull();
+ });
+
+ it('outside the map pass the position is unknown, not invented', async () => {
+ let release: () => void = () => {};
+ const { db } = fakeMongo({ collections: {} });
+ const orch = mkOrchestrator(db, {
+ switchCollection: async () => {},
+ hasRequiredIndex: async () => true,
+ ensureIndex: () => new Promise((r) => { release = r; }),
+ getLowerBound: async () => null,
+ getUpperBound: async () => null,
+ hasNullCdDocuments: async () => false,
+ });
+ const mapping = (orch as unknown as Mapper).mapCollection('drill_events_probe');
+ await waitUntil(() => orch.autoIndexState() !== null);
+ expect(orch.autoIndexState()).toMatchObject({ position: null, of: null });
+ release();
+ await mapping;
+ });
+});