Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no-issue]: Reduce flakiness in sync queue related tests #4170

Merged
merged 1 commit into from
Sep 15, 2022

Conversation

rohan-bes
Copy link
Collaborator

Since the change to making the ChangeHandlers run in a transaction, these sync queue related tests have all become a bit more flaky (eg. here, and here). They have previously been relying purely on timing at points, which isn't really all that safe. I've added a bunch of await database.waitForAllChangeHandlers(); calls in places where they seemed necessary, which should halt the test execution until the change transaction is complete.

- Code is still a bit unreliable, but now should properly wait for changes to be committed before continuing
Copy link
Contributor

@IgorNadj IgorNadj left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -74,6 +75,10 @@ describe('GET /changes/count', async () => {

// Add some more questions
await oneSecondSleep();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get rid of oneSecondSleep now? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we can 😞 The ChangeHandler won't schedule an execution until it receives a notification from the database that a change has occurred. If for some reason it takes the database longer to send a notification than it does for node to get to the next line, then calling waitForAllChangeHandlers() will complete instantly as no ChangeHandlers have been scheduled.

There's multiple levels of async stuff going on here 😅 It might just work though... I'm not really sure... but I don't think it'd be reliable...

@rohan-bes rohan-bes merged commit a195574 into dev Sep 15, 2022
@rohan-bes rohan-bes deleted the flakiness-in-sync-queue-tests branch September 15, 2022 05:35
This was referenced Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants