Skip to content

Commit 48a4477

Browse files
[FIXED] Parallel stream restore panic (#7503)
Due to the stream restore parallelization introduced in #7482, we can panic on `access time service not running`. Since `ats.Register()` can now be called in parallel as well. We can simply store an initial value, on startup it's no issue that this timestamp is only slightly stale. Signed-off-by: Maurice van Veen <[email protected]>
2 parents e2661b5 + c85269f commit 48a4477

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

server/ats/ats.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ func AccessTime() int64 {
7777
// Return last updated time.
7878
v := utime.Load()
7979
if v == 0 {
80-
panic("access time service not running")
80+
// Always register a time, the worst case is a stale time.
81+
// On startup, we can register in parallel and could previously panic.
82+
v = time.Now().UnixNano()
83+
utime.Store(v)
8184
}
8285
return v
8386
}

server/ats/ats_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ import (
1919
"time"
2020
)
2121

22-
func TestNotRunningPanic(t *testing.T) {
23-
defer func() {
24-
if r := recover(); r == nil {
25-
t.Errorf("Expected function to panic, but it did not")
26-
}
27-
}()
22+
func TestNotRunningValue(t *testing.T) {
2823
// Set back to zero in case this test gets run multiple times via --count.
2924
utime.Store(0)
30-
_ = AccessTime()
25+
at := AccessTime()
26+
if at == 0 {
27+
t.Fatal("Expected non-zero access time")
28+
}
29+
30+
atn := AccessTime()
31+
if atn != at {
32+
t.Fatal("Did not expect updates to access time")
33+
}
3134
}
3235

3336
func TestRegisterAndUnregister(t *testing.T) {

0 commit comments

Comments
 (0)