fix(shadow): recover closed source connections and retain diagnostics

This commit is contained in:
zgw
2026-09-10 11:55:59 +08:00
parent 4408958443
commit 0d53f41f1a
11 changed files with 363 additions and 6 deletions

View File

@@ -247,6 +247,7 @@ public final class Ft546ShadowScheduler implements AutoCloseable {
Duration backoff = readFailure.getRetryAfter().isZero() ? CRASH_BACKOFF : readFailure.getRetryAfter();
statusReport.markDegraded(reason, failedAt);
nextAttemptAt = failedAt.plus(backoff);
statusReport.recordCollectionFailure(reason, "SOURCE_READ", readFailure, failedAt, nextAttemptAt);
LOGGER.warn("FT546 shadow source read failed: {}; retry after {} ms",
reason, backoff.toMillis());
if (readFailure.getCause() != null) {
@@ -264,6 +265,7 @@ public final class Ft546ShadowScheduler implements AutoCloseable {
Instant failedAt = clock.instant();
statusReport.markDegraded("SHADOW_CYCLE_FAILED", failedAt);
nextAttemptAt = failedAt.plus(CRASH_BACKOFF);
statusReport.recordCollectionFailure("SHADOW_CYCLE_FAILED", activeStage.name(), failure, failedAt, nextAttemptAt);
LOGGER.error("FT546 shadow cycle failed", runtimeFailure);
return false;
}
@@ -293,6 +295,7 @@ public final class Ft546ShadowScheduler implements AutoCloseable {
permanentlyStopped.set(true);
nextAttemptAt = Instant.EPOCH;
statusReport.markPermanentlyDegraded(reasonCode, clock.instant());
statusReport.recordCollectionFailure(reasonCode, stage.name(), failure, clock.instant(), null);
LOGGER.error("FT546 shadow collection stopped: {}; stage={}; diagnostics={}",
reasonCode, stage, statusReport.getCycleDiagnostics(), failure);
return false;