From 0e68f26f8d4870380544baf6f41ad06d26c83c53 Mon Sep 17 00:00:00 2001 From: Matthew Mattox Date: Fri, 13 Nov 2026 12:09:42 -0600 Subject: [PATCH 1/2] test(goclusterfs): keep a crashed node's locks through the test replay remountAndReplay replayed the crashed node's journal as a new node without taking over the crashed node's lock claims, so its replay and the tests after it waited 15s for those claims to go stale. It now adopts them for the replay and releases them after, as mount does for a dead node. Co-Authored-By: Claude Opus 5.5 --- internal/goclusterfs/journal_crash_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/goclusterfs/journal_crash_test.go b/internal/goclusterfs/journal_crash_test.go index fe904be4..52ffc465 100644 --- a/internal/goclusterfs/journal_crash_test.go +++ b/internal/goclusterfs/journal_crash_test.go @@ -53,9 +53,21 @@ func crashAfterCommit(t *testing.T, fsys *FS, op string) <-chan struct{} { } // remountAndReplay opens the image as the next mount would and replays the journal. +// remountAndReplay opens the image as a new node and replays the crashed node's +// journal, keeping that node's locks through the replay as mount does. func remountAndReplay(t *testing.T, path string, offset, size uint64) *FS { t.Helper() fsys := openFormattedFS(t, path) + region, err := journal.OpenRegionForRecovery(fsys.dev, offset, size) + if err != nil { + t.Fatalf("open the crashed node's journal: %v", err) + } + crashed := region.Superblock().NodeUUID + // openFormattedFS puts each node's slot in the last byte of its UUID. + adopted, err := fsys.lockMgr.AdoptOwner(crashed, int(crashed[15])) + if err != nil { + t.Fatalf("take over the crashed node's locks: %v", err) + } replay := journal.CreateTxnRecoveryHandler(&journal.RecoveryContext{ Dev: fsys.dev, InodeTbl: fsys.inodeTbl, BitmapMgr: fsys.bitmapMgr, DirMgr: fsys.dirMgr, ExtentMgr: fsys.extentMgr, @@ -63,6 +75,9 @@ func remountAndReplay(t *testing.T, path string, offset, size uint64) *FS { if _, err := journal.ScanAndRecover(fsys.dev, offset, size, replay); err != nil { t.Fatalf("replay: %v", err) } + if err := fsys.lockMgr.ReleaseAdopted(adopted); err != nil { + t.Fatalf("release the crashed node's locks: %v", err) + } return fsys } From 284d83e2f20ec4427f1b8ad305caa35ad7759b85 Mon Sep 17 00:00:00 2001 From: Matthew Mattox Date: Fri, 13 Nov 2026 12:22:32 -0600 Subject: [PATCH 2/2] test(goclusterfs): drop the old remountAndReplay doc line Co-Authored-By: Claude Opus 5.5 --- internal/goclusterfs/journal_crash_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/goclusterfs/journal_crash_test.go b/internal/goclusterfs/journal_crash_test.go index 52ffc465..6e63dbf7 100644 --- a/internal/goclusterfs/journal_crash_test.go +++ b/internal/goclusterfs/journal_crash_test.go @@ -52,7 +52,6 @@ func crashAfterCommit(t *testing.T, fsys *FS, op string) <-chan struct{} { return crashed } -// remountAndReplay opens the image as the next mount would and replays the journal. // remountAndReplay opens the image as a new node and replays the crashed node's // journal, keeping that node's locks through the replay as mount does. func remountAndReplay(t *testing.T, path string, offset, size uint64) *FS {