mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
fix, status: retain attempt age and publish one cut observation
This commit is contained in:
1 parent
7534c0fc99
commit
74bb66fc99
6 files changed
+49
-15
No files matched your search
@@ -2,11 +2,13 @@ package durable_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/durable/testutil"
|
||||
"github.com/seaweedfs/seaweed-block/core/storage"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -72,6 +74,13 @@ func TestDurableStatusExposesTheCurrentCutWithoutWaitingForCommit(t *testing.T)
|
||||
if len(status) != 1 || status[0].Chunk == nil || status[0].Chunk.CurrentCut == nil || status[0].Chunk.CurrentCut.Phase != "commit" {
|
||||
t.Fatalf("status=%+v", status)
|
||||
}
|
||||
wire, err := json.Marshal(status)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Count(string(wire), `"CurrentCut"`) != 1 {
|
||||
t.Fatalf("CurrentCut must have one public location: %s", wire)
|
||||
}
|
||||
snapshot := *status[0].Chunk.CurrentCut
|
||||
release.Do(func() { close(remote.release) })
|
||||
select {
|
||||
|
||||
@@ -5,16 +5,18 @@ import "time"
|
||||
// CurrentCutStatus is an in-memory observation, never authority or a progress
|
||||
// guarantee. StartedAt is when this phase began; Attempt is local to this layer.
|
||||
type CurrentCutStatus struct {
|
||||
Phase string `json:"phase"`
|
||||
StartedAt time.Time `json:"started_at"`
|
||||
Attempt uint64 `json:"attempt"`
|
||||
AttemptStartedAt time.Time `json:"attempt_started_at"` // start of the whole attempt, unchanged across phase visits
|
||||
Phase string `json:"phase"` // current pipeline phase
|
||||
StartedAt time.Time `json:"started_at"` // UTC start of the current phase visit
|
||||
Attempt uint64 `json:"attempt"` // attachment-local attempt identity, including failed attempts
|
||||
}
|
||||
|
||||
func (l *chunkLayerImpl) startCutStatus() {
|
||||
l.stMu.Lock()
|
||||
defer l.stMu.Unlock()
|
||||
l.cutAttempt++
|
||||
l.currentCut = &CurrentCutStatus{Phase: "admit", StartedAt: time.Now().UTC(), Attempt: l.cutAttempt}
|
||||
now := time.Now().UTC()
|
||||
l.currentCut = &CurrentCutStatus{Phase: "admit", StartedAt: now, AttemptStartedAt: now, Attempt: l.cutAttempt}
|
||||
}
|
||||
func (l *chunkLayerImpl) clearCutStatus() {
|
||||
l.stMu.Lock()
|
||||
|
||||
@@ -48,7 +48,9 @@ func (r *currentCutHeldRemote) GetHead(ctx context.Context) (chunkHead, error) {
|
||||
}
|
||||
func currentCutJSON(t *testing.T, layer chunkLayer) map[string]any {
|
||||
t.Helper()
|
||||
raw, err := json.Marshal(layer.Stats())
|
||||
raw, err := json.Marshal(struct {
|
||||
CurrentCut *CurrentCutStatus `json:",omitempty"`
|
||||
}{layer.Stats().CurrentCut})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -93,6 +95,11 @@ func TestCurrentCutStatusNamesTheHeldPhaseAndClearsOnExit(t *testing.T) {
|
||||
if err != nil || started.IsZero() || started.After(time.Now()) {
|
||||
t.Fatalf("start=%v error=%v", started, err)
|
||||
}
|
||||
attemptTime, ok := cut["attempt_started_at"].(string)
|
||||
attemptStart, parseErr := time.Parse(time.RFC3339Nano, attemptTime)
|
||||
if !ok || parseErr != nil || attemptStart.After(started) {
|
||||
t.Fatalf("attempt start missing or newer than phase: %v", cut)
|
||||
}
|
||||
attempt := cut["attempt"].(float64)
|
||||
if attempt < 1 {
|
||||
t.Fatalf("attempt=%v", cut)
|
||||
|
||||
@@ -459,7 +459,7 @@ type chunkCutStats struct {
|
||||
// successful cuts of this layer (in-process): it identifies the latest
|
||||
// cut and orders cuts without any clock.
|
||||
type chunkLayerStats struct {
|
||||
CurrentCut *CurrentCutStatus `json:",omitempty"`
|
||||
CurrentCut *CurrentCutStatus `json:"-"` // status plumbing; published only as Chunk.CurrentCut
|
||||
Hydration ChunkHydrationStats // lazy fetches of absent chunks from the remote
|
||||
CutsOK uint64 // cuts that installed a HEAD
|
||||
CutsNoop uint64 // cuts with nothing new (no CAS)
|
||||
|
||||
@@ -62,11 +62,30 @@ The holder's `/status/durable` response exposes `Volumes[].Chunk.CurrentCut`
|
||||
while a cut is active, and omits it when idle. Its typed `phase` is one of
|
||||
`admit`, `recover`, `stage`, `barrier`, `candidates`, `compare`, `upload`,
|
||||
`commit`, or `settle`; `started_at` is the UTC time the current phase began,
|
||||
and `attempt` identifies the attempt within this layer's lifetime. Repeated
|
||||
phase visits retain the attempt but start a new phase time. These are in-memory
|
||||
`attempt_started_at` is the start of the whole attempt, and `attempt` identifies
|
||||
the attempt within this layer's lifetime. Repeated
|
||||
phase visits retain the attempt and its start time but start a new phase time.
|
||||
A scheduled no-op may briefly show `admit` and other phases even on an idle
|
||||
volume; absence between polls does not prove no attempt occurred. These are in-memory
|
||||
observations, reset on a new attachment, and are never authority, ordering or
|
||||
proof of persistence. A status read does not wait for the cut's remote I/O.
|
||||
Runner boundary triggers use these typed fields rather than parsing log text.
|
||||
Only `Chunk.CurrentCut` is published; the counters do not expose a second copy.
|
||||
|
||||
| Status phase | Log measurement covering the phase |
|
||||
| --- | --- |
|
||||
| `admit` | `total_ms` (admission and budget wait have no separate logged span) |
|
||||
| `recover` | `total_ms`; pending recovery is outside publication spans |
|
||||
| `stage` | `total_ms`; pre-barrier staging has no separate logged span |
|
||||
| `barrier` | `total_ms`; lock/drain/sync have no separate logged span |
|
||||
| `candidates` | `candidates_ms` |
|
||||
| `compare` | `compare_prepare_ms` and copy work within `upload_ms` |
|
||||
| `upload` | `upload_ms`; session admission also contributes to `compare_prepare_ms` |
|
||||
| `commit` | `commit_ms`, including `head_write_ms` |
|
||||
| `settle` | `settle_ms` (readback, local state and map persistence) |
|
||||
|
||||
These are overlapping completion-dependent measurements, not a partition of
|
||||
attempt time. The zero, recovery and failure boundaries above still apply.
|
||||
|
||||
## Clock safety requirement
|
||||
|
||||
|
||||
@@ -211,18 +211,15 @@ Durable store state of the served volume. Go type `volume.durableStatusBody`.
|
||||
| `Volumes[].CheckpointPersistence.LastAdvance` | time (RFC 3339) | when the latest advance happened; zero if none in this open |
|
||||
| `Volumes[].Chunk` | object | Chunk is the chunk layer's state and cut counters; walstore-chunk volumes only. |
|
||||
| `Volumes[].Chunk.CurrentCut` | object | active cut phase; absent when idle (omitted when empty) |
|
||||
| `Volumes[].Chunk.CurrentCut.phase` | string | — |
|
||||
| `Volumes[].Chunk.CurrentCut.started_at` | time (RFC 3339) | — |
|
||||
| `Volumes[].Chunk.CurrentCut.attempt` | uint64 | — |
|
||||
| `Volumes[].Chunk.CurrentCut.attempt_started_at` | time (RFC 3339) | start of the whole attempt, unchanged across phase visits |
|
||||
| `Volumes[].Chunk.CurrentCut.phase` | string | current pipeline phase |
|
||||
| `Volumes[].Chunk.CurrentCut.started_at` | time (RFC 3339) | UTC start of the current phase visit |
|
||||
| `Volumes[].Chunk.CurrentCut.attempt` | uint64 | attachment-local attempt identity, including failed attempts |
|
||||
| `Volumes[].Chunk.Attached` | bool | the chunk layer is attached to the remote |
|
||||
| `Volumes[].Chunk.AwaitingAuthority` | bool | recovered; the layer waits for master authority to attach |
|
||||
| `Volumes[].Chunk.Fenced` | bool | a newer holder fenced this layer: it publishes nothing |
|
||||
| `Volumes[].Chunk.RemoteLSN` | uint64 | the LSN of the remote HEAD (what the remote holds durably) |
|
||||
| `Volumes[].Chunk.Stats` | object | the layer's cut counters; zero until attached |
|
||||
| `Volumes[].Chunk.Stats.CurrentCut` | object | — (omitted when empty) |
|
||||
| `Volumes[].Chunk.Stats.CurrentCut.phase` | string | — |
|
||||
| `Volumes[].Chunk.Stats.CurrentCut.started_at` | time (RFC 3339) | — |
|
||||
| `Volumes[].Chunk.Stats.CurrentCut.attempt` | uint64 | — |
|
||||
| `Volumes[].Chunk.Stats.Hydration` | object | lazy fetches of absent chunks from the remote |
|
||||
| `Volumes[].Chunk.Stats.Hydration.WorkerLimit` | int | fetch workers allowed (--chunk-hydration-workers) |
|
||||
| `Volumes[].Chunk.Stats.Hydration.QueueDepth` | int | fetch queue capacity (--chunk-hydration-queue-depth) |
|
||||
|
||||
Reference in new issue
Block a user