diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/indexer/run.rs | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/indexer/run.rs b/src/indexer/run.rs index fae9cd1..1578590 100644 --- a/src/indexer/run.rs +++ b/src/indexer/run.rs @@ -100,6 +100,13 @@ fn red_mode() -> Option<String> { std::env::var("GN4_INDEXER_RED").ok() } +/// Test-only hooks that can hang or reshape a run (park after N commits, +/// override the commit chunk) are inert unless this opt-in is set, so an +/// accidental environment variable cannot affect a production run. +fn test_hooks_enabled() -> bool { + std::env::var("GN4_INDEXER_TEST_HOOKS").as_deref() == Ok("1") +} + /// RED: skip the startup shard-integrity check and swallow a corrupt or /// unreadable shard as empty (the silent-skip regression the check /// closes). @@ -315,15 +322,26 @@ impl CommitPacer { let log_path = std::env::var("GN4_INDEXER_COMMIT_LOG") .ok() .map(PathBuf::from); - let halt_after = std::env::var("GN4_INDEXER_HALT_AFTER_COMMITS") - .ok() - .and_then(|value| value.parse().ok()); + // The parking hook and the chunk override can hang or reshape a + // run, so they stay inert unless GN4_INDEXER_TEST_HOOKS opts in. + let hooks = test_hooks_enabled(); + let halt_after = if hooks { + std::env::var("GN4_INDEXER_HALT_AFTER_COMMITS") + .ok() + .and_then(|value| value.parse().ok()) + } else { + None + }; // The production chunk size is COMMIT_CHUNK_DOCS; the crash gate // overrides it downward so a small mix spans several chunks. - let chunk = std::env::var("GN4_INDEXER_COMMIT_CHUNK") - .ok() - .and_then(|value| value.parse().ok()) - .unwrap_or(COMMIT_CHUNK_DOCS); + let chunk = if hooks { + std::env::var("GN4_INDEXER_COMMIT_CHUNK") + .ok() + .and_then(|value| value.parse().ok()) + .unwrap_or(COMMIT_CHUNK_DOCS) + } else { + COMMIT_CHUNK_DOCS + }; CommitPacer { chunk, open: false, |
