fix, logging: keep idle cut attempts at DEBUG

This commit is contained in:
pingqiu committed 2026-11-28 21:49:21 -08:00
1 parent 619f1de421
commit a5515a9be5
3 files changed
+22 -7

No files matched your search

@@ -38,8 +38,15 @@ func TestCutPhaseTimingAtDefaultInfoKeepsTheMeasuredHeadTime(t *testing.T) {
if r, err := layer.Cut(ctTimeout(t)); err != nil || !r.Noop {
t.Fatalf("no-op control: %+v %v", r, err)
}
if strings.Count(out.String(), "cut phases") != 1 || !strings.Contains(out.String(), "level=INFO") || !strings.Contains(out.String(), "noop=true") {
t.Fatalf("default INFO omitted a no-op attempt: %s", out.String())
if strings.Contains(out.String(), "cut phases") {
t.Fatalf("default INFO exposed a successful no-op: %s", out.String())
}
_ = logging.Configure("debug")
if r, err := layer.Cut(ctTimeout(t)); err != nil || !r.Noop {
t.Fatalf("debug no-op control: %+v %v", r, err)
}
if strings.Count(out.String(), "cut phases") != 1 || !strings.Contains(out.String(), "level=DEBUG") || !strings.Contains(out.String(), "noop=true") || !strings.Contains(out.String(), `err=""`) {
t.Fatalf("debug omitted the successful no-op: %s", out.String())
}
out.Reset()
writes.write(t, s, 2, 0x41)
+9 -1
View File
@@ -31,6 +31,8 @@ import (
"sync"
"sync/atomic"
"time"
"github.com/seaweedfs/seaweed-block/internal/logging"
)
// chunkHooks is what the WALStore holds for an attached layer.
@@ -726,6 +728,7 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
}
defer done()
start := time.Now()
recoveredPublication := l.pending != nil
var st chunkCutStats
persistCapturedMap := func(versions map[uint64]uint64) {
start := time.Now()
@@ -774,7 +777,12 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
}
// Existing spans overlap (upload includes copy, commit includes its
// HEAD exchange); report observations, never add them into a new total.
log.Printf("level=INFO storage: cut phases phase_scope=publication volume=%q holder=%q epoch=%d h=%d noop=%t candidates=%d uploaded=%d candidates_ms=%.3f compare_prepare_ms=%.3f upload_ms=%.3f commit_ms=%.3f head_write_ms=%.3f settle_ms=%.3f total_ms=%.3f err=%q",
// Pending recovery can write HEAD even when normal publication is a no-op.
emit := func(format string, args ...any) { log.Printf("level=INFO "+format, args...) }
if err == nil && res.Noop && !recoveredPublication && st.CandidateChunks == 0 && st.UploadedChunks == 0 {
emit = logging.Debugf
}
emit("storage: cut phases phase_scope=publication volume=%q holder=%q epoch=%d h=%d noop=%t candidates=%d uploaded=%d candidates_ms=%.3f compare_prepare_ms=%.3f upload_ms=%.3f commit_ms=%.3f head_write_ms=%.3f settle_ms=%.3f total_ms=%.3f err=%q",
l.cfg.VolumeID, l.cfg.Holder, l.cfg.Epoch, res.H, res.Noop, st.CandidateChunks, st.UploadedChunks,
float64(st.CandidateNs)/1e6, float64(st.PublishPrepareNs)/1e6, float64(st.UploadNs)/1e6,
float64(st.CASNs)/1e6, float64(st.CASWriteNs)/1e6,
+4 -4
View File
@@ -22,8 +22,8 @@ that runs it.
`blockmaster` and `blockvolume` accept `--log-level info|debug` (default
`info`). For the CLI, put the global flag before the subcommand:
`sw-block --log-level debug ops workspace show ...`. This configures the DEBUG
filter. HEAD writes and cut-phase diagnostics remain INFO at both settings;
the current logging update adds no debug-only diagnostics.
filter. HEAD writes and failed or working cut attempts remain INFO at both settings;
successful cut no-ops without pending recovery or candidate/upload work appear only at DEBUG.
An unsupported level is refused before the command runs.
Standard log timestamps are UTC with six fractional digits, for example
@@ -36,8 +36,8 @@ the expected generation: it describes an attempt, never proof of persistence.
Log timestamps are observations, not authority or ordering
proofs: use the generation and session fields to correlate writes.
At the default INFO level, every cut attempt (including failures and no-ops)
reports `storage: cut phases`: `candidates_ms`
At the default INFO level, failed cut attempts and attempts that do work
report `storage: cut phases`: `candidates_ms`
is the existing candidate-scan span; `compare_prepare_ms` includes comparison,
proposal preparation and session admission; `upload_ms` includes copy/upload;
`commit_ms` includes the HEAD exchange, also shown as `head_write_ms`;