diff options
| author | Alexander_Kabui <alexanderkabui@proton.me> | 2026-10-13 15:11:33 +0300 |
|---|---|---|
| committer | Alexander_Kabui <alexanderkabui@proton.me> | 2026-10-14 07:27:03 +0300 |
| commit | b0c027a40c1e64d5c3a6b7e5dd79d1f3c4cb35eb (patch) | |
| tree | 68d6c58e115c3147c7bec38f302df81f12943fe4 /src | |
| parent | adde6d8e8d80246c099c4b39e82f34faa0d14d9a (diff) | |
| download | genenetwork4-b0c027a40c1e64d5c3a6b7e5dd79d1f3c4cb35eb.tar.gz | |
* src/indexer/run.rs (test hooks): require GN4_INDEXER_TEST_HOOKS.
GN4_INDEXER_HALT_AFTER_COMMITS parks the process and GN4_INDEXER_COMMIT_CHUNK reshapes the commit cadence; either set by accident in a production environment could hang or change a run. Make both inert unless GN4_INDEXER_TEST_HOOKS=1.
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, |
