From ff6cca1bf90cc7ec0267deaa95bd527abd3a3700 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Sun, 28 Apr 2024 14:09:40 +0200 Subject: [PATCH] fix flaky test: close account before marking thread-upgrade as finished store/threads_test.go opens an account, starts the threading upgrade, waits for it to finish, runs some tests, and closes the account at the end, verifying all references are gone. the "thread upgrade" goroutine has its own account reference. it closes its account after having signaled completion of the upgrade. in between that time, all checks from the tests could run, its account closed and its no-more-account-references check would fail. the fix is hopefully to mark the thread upgrade process finished after closing the account. hard to verify, but this only happens very rarely. --- store/account.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/store/account.go b/store/account.go index 67e110c..b2577d2 100644 --- a/store/account.go +++ b/store/account.go @@ -1016,6 +1016,9 @@ func OpenAccountDB(log mlog.Log, accountDir, accountName string) (a *Account, re defer func() { err := closeAccount(acc) log.Check(err, "closing use of account after upgrading account storage for threads", slog.String("account", a.Name)) + + // Mark that upgrade has finished, possibly error is indicated in threadsErr. + close(acc.threadsCompleted) }() defer func() { @@ -1026,9 +1029,6 @@ func OpenAccountDB(log mlog.Log, accountDir, accountName string) (a *Account, re metrics.PanicInc(metrics.Upgradethreads) acc.threadsErr = fmt.Errorf("panic during upgradeThreads: %v", x) } - - // Mark that upgrade has finished, possibly error is indicated in threadsErr. - close(acc.threadsCompleted) }() err := upgradeThreads(mox.Shutdown, log, acc, &up)