diff --git a/src/pipeline/pipeline.c b/src/pipeline/pipeline.c index 0c3041959..5cc163941 100644 --- a/src/pipeline/pipeline.c +++ b/src/pipeline/pipeline.c @@ -401,7 +401,19 @@ static int effective_worker_count(bool initial) { if (st && st[0] == '1') { return 1; } - return cbm_default_worker_count(initial); + /* Keep the explicit override available for parallel regression tests and + * deliberate diagnostics. It is opt-in; the production default below stays + * on the crash-free sequential path. */ + if (getenv("CBM_WORKERS")) { + return cbm_default_worker_count(initial); + } + (void)initial; + /* Parallel extraction currently corrupts heap state on real mixed-language + * repositories (reproduced with two or more workers on Serena). Keep the + * production indexing path deterministic and crash-free until the shared + * parser/allocator race is fixed. Correctness is more important than the + * parallel speedup. */ + return 1; } /* Resolve the DB path for this pipeline. Caller must free(). */ diff --git a/tests/test_pipeline.c b/tests/test_pipeline.c index 6cb2a6150..50646838c 100644 --- a/tests/test_pipeline.c +++ b/tests/test_pipeline.c @@ -7192,6 +7192,9 @@ TEST(pipeline_backpressure_futile_nap_disengages) { ASSERT_TRUE(cbm_mem_over_budget()); cbm_pp_bp_nap_cycles_reset(); + char *old_workers = getenv("CBM_WORKERS"); + char *saved_workers = old_workers ? strdup(old_workers) : NULL; + cbm_setenv("CBM_WORKERS", "4", 1); char db_path[512]; snprintf(db_path, sizeof(db_path), "%s/backpressure.db", g_tmpdir); cbm_pipeline_t *p = cbm_pipeline_new(g_tmpdir, db_path, CBM_MODE_FULL); @@ -7201,6 +7204,12 @@ TEST(pipeline_backpressure_futile_nap_disengages) { /* Restore the caller-visible budget BEFORE asserting. */ cbm_mem_set_budget_for_tests(saved_budget); + if (saved_workers) { + cbm_setenv("CBM_WORKERS", saved_workers, 1); + free(saved_workers); + } else { + cbm_unsetenv("CBM_WORKERS"); + } cbm_pipeline_free(p); teardown_test_repo();