mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 15:04:37 +00:00
fix: remove nil-optional superMu pattern, require in all FlusherConfigs
superMu is mandatory for correctness — all superblock mutation+persist must be serialized. Remove the nil guard in updateSuperblockCheckpoint and add SuperMu to all 7 test FlusherConfig sites. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
3ddb87adc9
commit
e8c921d9e8
@@ -1495,6 +1495,7 @@ func testQAFlushCheckpointPersists(t *testing.T) {
|
||||
f := NewFlusher(FlusherConfig{
|
||||
FD: v.fd,
|
||||
Super: &v.super,
|
||||
SuperMu: &v.superMu,
|
||||
WAL: v.wal,
|
||||
DirtyMap: v.dirtyMap,
|
||||
Interval: 1 * time.Hour,
|
||||
@@ -1586,6 +1587,7 @@ func testQAFlushWALReclaimThenWrite(t *testing.T) {
|
||||
f := NewFlusher(FlusherConfig{
|
||||
FD: v.fd,
|
||||
Super: &v.super,
|
||||
SuperMu: &v.superMu,
|
||||
WAL: v.wal,
|
||||
DirtyMap: v.dirtyMap,
|
||||
Interval: 1 * time.Hour,
|
||||
@@ -1849,6 +1851,7 @@ func testQARecoverAfterFlushThenCrash(t *testing.T) {
|
||||
|
||||
f := NewFlusher(FlusherConfig{
|
||||
FD: v.fd, Super: &v.super, WAL: v.wal, DirtyMap: v.dirtyMap,
|
||||
SuperMu: &v.superMu,
|
||||
Interval: 1 * time.Hour,
|
||||
})
|
||||
if err := f.FlushOnce(); err != nil {
|
||||
@@ -3413,6 +3416,7 @@ func testQAFlushPartialWALWrap(t *testing.T) {
|
||||
f := NewFlusher(FlusherConfig{
|
||||
FD: v.fd,
|
||||
Super: &v.super,
|
||||
SuperMu: &v.superMu,
|
||||
WAL: v.wal,
|
||||
DirtyMap: v.dirtyMap,
|
||||
Interval: 1 * time.Hour, // manual only
|
||||
|
||||
@@ -420,10 +420,8 @@ func (f *Flusher) flushOnceLocked() error {
|
||||
// updateSuperblockCheckpoint writes the updated checkpoint to disk.
|
||||
// Acquires superMu to serialize against syncWithWALProgress (group commit).
|
||||
func (f *Flusher) updateSuperblockCheckpoint(checkpointLSN uint64, walTail uint64) error {
|
||||
if f.superMu != nil {
|
||||
f.superMu.Lock()
|
||||
defer f.superMu.Unlock()
|
||||
}
|
||||
f.superMu.Lock()
|
||||
defer f.superMu.Unlock()
|
||||
|
||||
f.super.WALCheckpointLSN = checkpointLSN
|
||||
f.super.WALHead = f.wal.LogicalHead()
|
||||
|
||||
@@ -48,6 +48,7 @@ func createTestVolWithFlusher(t *testing.T) (*BlockVol, *Flusher) {
|
||||
f := NewFlusher(FlusherConfig{
|
||||
FD: v.fd,
|
||||
Super: &v.super,
|
||||
SuperMu: &v.superMu,
|
||||
WAL: v.wal,
|
||||
DirtyMap: v.dirtyMap,
|
||||
Interval: 1 * time.Hour, // don't auto-flush in tests
|
||||
@@ -343,6 +344,7 @@ func testFlusherErrorLogged(t *testing.T) {
|
||||
f := NewFlusher(FlusherConfig{
|
||||
FD: closedFD,
|
||||
Super: &v.super,
|
||||
SuperMu: &v.superMu,
|
||||
WAL: v.wal,
|
||||
DirtyMap: v.dirtyMap,
|
||||
Interval: 1 * time.Hour,
|
||||
|
||||
@@ -230,6 +230,7 @@ func testRecoverAfterCheckpoint(t *testing.T) {
|
||||
f := NewFlusher(FlusherConfig{
|
||||
FD: v.fd,
|
||||
Super: &v.super,
|
||||
SuperMu: &v.superMu,
|
||||
WAL: v.wal,
|
||||
DirtyMap: v.dirtyMap,
|
||||
Interval: 1 * time.Hour,
|
||||
|
||||
Reference in New Issue
Block a user