Skip to content

Fix flaky TransactionTests.testResponseStreamFails() test #582

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

Merged
merged 7 commits into from
Apr 22, 2022

Conversation

dnadoba
Copy link
Collaborator

@dnadoba dnadoba commented Apr 21, 2022

Motivation

EmbeddedEventLoop event loop is not thread-safe but we create a EventLoopFuture that is required to be thread-safe from an EmbeddedEventLoop. This leads to undefined behaviour and therefore a flaky test.

Modification

This PR replaces the EventLoopFuture with a simple Promise implementation that uses Swift Concurrency to protect against concurrent access.

Result

Before this patch, I could reliably fail the test after ~5K repetitions.
With this patch, I have run the test 100K times without a single failure.

Note: this only effects code in the test target

@dnadoba dnadoba added the semver/none No version bump required. label Apr 21, 2022
@dnadoba dnadoba requested a review from fabianfett April 21, 2022 09:42
Copy link
Collaborator

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Nice, this LGTM.

@dnadoba
Copy link
Collaborator Author

dnadoba commented Apr 22, 2022

5.7 & nightly fail because of sendable related errors.

@dnadoba dnadoba merged commit a586fba into swift-server:main Apr 22, 2022
@dnadoba dnadoba deleted the dn-fix-flaky-transaction-test branch April 22, 2022 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants