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

fix: prevent notifier test flakiness#14467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dannykopping merged 1 commit intomainfromdk/notifier-paused
Aug 28, 2024
Merged

Conversation

dannykopping
Copy link
Contributor

@dannykoppingdannykopping commentedAug 28, 2024
edited
Loading

Fixescoder/internal#281

There was a TOCTOU race between checking whether the notifier should pause and processing the messages:

// run is the main loop of the notifier.func (n*notifier)run(ctx context.Context,successchan<-dispatchResult,failurechan<-dispatchResult)error {...for {...// Check if notifier is not paused.ok,err:=n.ensureRunning(ctx)iferr!=nil {n.log.Warn(ctx,"failed to check notifier state",slog.Error(err))    }ifok {// <---- if the notifier was paused at this point, any pending messages would still be processed.// Call process() immediately (i.e. don't wait an initial tick).err=n.process(ctx,success,failure)iferr!=nil {n.log.Error(ctx,"failed to process messages",slog.Error(err))    }    }...  }...

I'm of the opinion that we don't need to fix this in the code itself (it's not super critical that pausing the notifier is effectedimmediately); it was just a problem for the tests.

Previously in the tests:

  1. The manager was started first
  2. A message was enqueued
  3. Notifier ticked, to process notifications
  4. Notifier is determined to be paused (while already inprocess method) <--TOCTOU
  5. Notification is processed

Now:

  1. Message is enqueued
  2. Manager is started
  3. Notifier ticked, to process notifications
  4. Notifier is determined to be paused,process method exits

Signed-off-by: Danny Kopping <danny@coder.com>
@dannykoppingdannykopping marked this pull request as ready for reviewAugust 28, 2024 14:19
Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍 I'm fine with this approach if it stops the flakes for now, but Quartz is a better solution overall.

dannykopping reacted with thumbs up emoji
@dannykopping
Copy link
ContributorAuthor

👍 I'm fine with this approach if it stops the flakes for now, but Quartz is a better solution overall.

Indeed. We still havecoder/internal#6 which could be picked up; it'll take some doing to plumb it all through.

@dannykoppingdannykopping merged commitf24cb5c intomainAug 28, 2024
39 checks passed
@dannykoppingdannykopping deleted the dk/notifier-paused branchAugust 28, 2024 14:33
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 28, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@ethanndicksonethanndicksonAwaiting requested review from ethanndickson

Assignees

@dannykoppingdannykopping

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

flake:TestNotifierPaused
2 participants
@dannykopping@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp