Files
seaweedfs/weed/filer/filer_sync_cursor.go
T
Chris LuandClaude Opus 5.5 c637d60dfc filer.sync: keep an informational replay cursor on the source, and let the log purge honor it (#13176)
* filer.sync: save the sync position on the source filer as a replay cursor

The position stays authoritative on the target. The source copy holds the
last position the target checkpoint stored (a fresh sync without one holds
just before the first event it received) and is rewritten hourly while the
sync runs, even when the position does not move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer.sync: do not replicate the sync cursors of the source

A target never holds cursors that describe the source's log. A rename into
or out of the cursor directory replicates the ordinary side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* metadata log purge: keep the logs a filer.sync still needs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer.sync: describe the sync in its source cursor

The source cursor is informational: besides the position it records the
source and target filers and paths, exclusions, host, version, when the
sync started, whether the position is a target checkpoint, and the
processed and failed event times, for display in admin tools. The
target checkpoint stays authoritative.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer.sync: save the first sync cursor when the first event arrives and retry failed saves

A fresh sync only saved its cursor on the next minute tick, and a failed
save still pushed the next attempt out by an hour, leaving the purge
without a cursor while the sync replayed old log days.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer.backup: do not seed the source's sync cursors in the initial snapshot

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* metadata log purge: say that a position not saved for 7 days stops holding the log

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer.backup test: lock the recording sink for concurrent snapshot workers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer.sync: leave the sync cursors out of the metadata log gap check

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 13:09:23 -08:00

25 lines
1.1 KiB
Go

package filer
// SyncCursor is what a filer.sync keeps on its source filer under
// SyncCursorDir. TsNs holds back the metadata log purge there; the other
// fields describe the sync for display. The checkpoint stored on the target
// filer stays the authoritative sync position.
type SyncCursor struct {
TsNs int64 `json:"ts_ns"`
SavedNs int64 `json:"saved_ns"`
// Checkpointed is false while a fresh sync has no target checkpoint yet
// and TsNs is held just before the first event it received.
Checkpointed bool `json:"checkpointed"`
ProcessedTsNs int64 `json:"processed_ts_ns,omitempty"`
OldestFailedTsNs int64 `json:"oldest_failed_ts_ns,omitempty"`
SourceFiler string `json:"source_filer"`
SourcePath string `json:"source_path"`
ExcludePaths []string `json:"exclude_paths,omitempty"`
TargetFiler string `json:"target_filer"`
TargetPath string `json:"target_path"`
TargetSignature int32 `json:"target_signature"`
Host string `json:"host,omitempty"`
Version string `json:"version,omitempty"`
SyncStartedNs int64 `json:"sync_started_ns"`
}