Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit31c3351

Browse files
committed
address race condition in initial tick
1 parentb20fb2f commit31c3351

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎coderd/database/dbpurge/dbpurge.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ func New(ctx context.Context, logger slog.Logger, db database.Store, clk quartz.
3131
//nolint:gocritic // The system purges old db records without user input.
3232
ctx=dbauthz.AsSystemRestricted(ctx)
3333

34-
ticker:=clk.NewTicker(time.Nanosecond)
34+
// Start the ticker with the initial delay.
35+
ticker:=clk.NewTicker(delay)
3536
doTick:=func(start time.Time) {
3637
deferticker.Reset(delay)
3738
// Start a transaction to grab advisory lock, we don't want to run
@@ -74,6 +75,8 @@ func New(ctx context.Context, logger slog.Logger, db database.Store, clk quartz.
7475
gofunc() {
7576
deferclose(closed)
7677
deferticker.Stop()
78+
// Force an initial tick immediately.
79+
ticker.Reset(time.Nanosecond)
7780
for {
7881
select {
7982
case<-ctx.Done():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp