Skip to content

Commit 601dcbf

Browse files
committed
fix(pipeline): name every silent failure edge in generation finalize
The Cyrillic guard failure came down to this: the worker indexes the repo perfectly (gbuf.dump nodes=12 edges=21, DB written, sealed, sidecars staged) and then finalize fails somewhere between stage_sidecars and prepare_live -- and every failure edge on that path returns PERSIST_FAILED without a word. The user then reads "Pipeline failed. Check repo_path exists and contains source files" about a repo that indexed flawlessly. A silent failure that misattributes itself cost a full day of remote-only bisection: five instrumentation commits in the TEST were needed to even locate the failing function. That is a product defect independent of the original bug. Every edge now logs before returning -- destination-not-regular, seal rc, sidecar-cleanup errno (both branches), and the final rename with stage and destination paths. The next guard run names the exact edge and value instead of requiring a sixth probe. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent aac3616 commit 601dcbf

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

‎src/pipeline/pipeline.c‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,24 +1608,45 @@ static int prepare_existing_generation_for_replace(const char *db_path,
16081608
return CBM_PIPELINE_PERSIST_FAILED;
16091609
}
16101610
memset(prepared, 0, sizeof(*prepared));
1611+
/* Every failure edge below logs before returning: a silent PERSIST_FAILED
1612+
* surfaces to the user as "Pipeline failed. Check repo_path ..." -- blaming
1613+
* a repo that indexed perfectly for a destination-side replacement fault. */
16111614
cbm_path_info_t info;
16121615
if (cbm_path_info_utf8(db_path, &info) == 0) {
16131616
if (!info.is_regular || info.is_symlink) {
1617+
cbm_log_error("finalize.prepare_failed", "reason", "destination_not_regular", "path",
1618+
db_path);
16141619
return CBM_PIPELINE_PERSIST_FAILED;
16151620
}
16161621
int seal_rc = cbm_store_seal_existing_path_for_replace(db_path);
16171622
if (seal_rc == CBM_STORE_NOT_FOUND) {
16181623
if (!quarantine_invalid) {
16191624
(void)cbm_unlink(db_path);
1620-
return cbm_remove_db_sidecars(db_path) == 0 ? 0 : CBM_PIPELINE_PERSIST_FAILED;
1625+
if (cbm_remove_db_sidecars(db_path) != 0) {
1626+
cbm_log_error("finalize.prepare_failed", "reason",
1627+
"invalid_destination_sidecar_cleanup", "path", db_path);
1628+
return CBM_PIPELINE_PERSIST_FAILED;
1629+
}
1630+
return 0;
16211631
}
16221632
return quarantine_existing_generation(db_path, prepared);
16231633
}
16241634
if (seal_rc != CBM_STORE_OK) {
1635+
char seal_text[16];
1636+
(void)snprintf(seal_text, sizeof(seal_text), "%d", seal_rc);
1637+
cbm_log_error("finalize.prepare_failed", "reason", "seal_existing", "rc", seal_text,
1638+
"path", db_path);
16251639
return CBM_PIPELINE_PERSIST_FAILED;
16261640
}
16271641
}
1628-
return cbm_remove_db_sidecars(db_path) == 0 ? 0 : CBM_PIPELINE_PERSIST_FAILED;
1642+
if (cbm_remove_db_sidecars(db_path) != 0) {
1643+
char errno_text[16];
1644+
(void)snprintf(errno_text, sizeof(errno_text), "%d", errno);
1645+
cbm_log_error("finalize.prepare_failed", "reason", "sidecar_cleanup", "errno", errno_text,
1646+
"path", db_path);
1647+
return CBM_PIPELINE_PERSIST_FAILED;
1648+
}
1649+
return 0;
16291650
}
16301651

16311652
int cbm_pipeline_publish_generation(const cbm_pipeline_generation_t *generation) {
@@ -1807,6 +1828,10 @@ int cbm_pipeline_finalize_staged_generation(char *stage_path, const char *final_
18071828
* generation's WAL. */
18081829
if (destination_known_healthy) {
18091830
if (cbm_remove_db_sidecars(final_db_path) != 0) {
1831+
char errno_text[16];
1832+
(void)snprintf(errno_text, sizeof(errno_text), "%d", errno);
1833+
cbm_log_error("finalize.prepare_failed", "reason", "healthy_sidecar_cleanup", "errno",
1834+
errno_text, "path", final_db_path);
18101835
cbm_pipeline_discard_stage(stage_path);
18111836
return CBM_PIPELINE_PERSIST_FAILED;
18121837
}
@@ -1828,6 +1853,10 @@ int cbm_pipeline_finalize_staged_generation(char *stage_path, const char *final_
18281853
itoa_buf((int)elapsed_ms(t_fin)));
18291854
cbm_clock_gettime(CLOCK_MONOTONIC, &t_fin);
18301855
if (cbm_rename_replace(stage_path, final_db_path) != 0) {
1856+
char errno_text[16];
1857+
(void)snprintf(errno_text, sizeof(errno_text), "%d", errno);
1858+
cbm_log_error("finalize.rename_failed", "errno", errno_text, "stage", stage_path, "dest",
1859+
final_db_path);
18311860
(void)rollback_quarantined_generation(final_db_path, &prepared);
18321861
discard_generation_stage(stage_path);
18331862
return CBM_PIPELINE_PERSIST_FAILED;

0 commit comments

Comments
 (0)