-
Notifications
You must be signed in to change notification settings - Fork 37.8k
tests: Write the notification message to different files to avoid race condition in feature_notifications.py #14275
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
tests: Write the notification message to different files to avoid race condition in feature_notifications.py #14275
Conversation
Note to reviewers: This pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
utACK f8b6424a1014e8080f22b39a6d3b9998e85f2f90 |
Could you explain the race condition? |
Bitcoin Core runs the each notification command in new thread, so it would have 10 process writing the same file if it generate 10 blocks immediately in this tests. |
Maybe on a second thought the tests should mirror how the notifications are supposed to be used in practice. If we don't support support filesystems that deny access when a lock is taken, as opposed to waiting, then the test shouldn't run on that system. |
Instead of sleeping between the blocknotify commands, so they can all write to the same file, what about just having them write to different files. E.g. create a |
@ryanofsky suggestion is good to fix the problem. But I wonder if we should replace the "call system with user command in a new thread" with a FIFO notification thread? |
@ryanofsky Updated the commit. Now the test create empty files with different name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last commit looks good to me, modulo the comment nits. I have not reviewed the first two commits which are from #14007.
@@ -36,54 +39,49 @@ def run_test(self): | |||
blocks = self.nodes[1].generate(block_count) | |||
|
|||
# wait at most 10 seconds for expected file size before reading the content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: comment should be updated: ...expected directory size...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also the comments below this one that refer to "file contents" should be "directory contents"
utACK 67654b6 |
…s to avoid race condition in feature_notifications.py 67654b6 tests: write the notification to different files to avoid race condition (Chun Kuan Lee) Pull request description: This PR change the behavior that `feature_notifications.py` would write to different files instead of writing to the same file to avoid race condition. Tree-SHA512: 78406167cc6a3f570134b0ee76d2be1440bc1498cd7b1be72fae16d0ab86950e26ef3bf6008796016e5418231400c6492f0e062909dd882646541ecb7a70fb30
Summary: Backport of core [[bitcoin/bitcoin#14275 | PR14275]]. This is slighly adapted to not reduce large fork coverage but allow the test to pass on windows. Test Plan: ./test/functional/test_runner.py feature_notifications Ran on Linux, windows (depends on D5964) and OSX for sanity. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5966
Summary: Backport of core [[bitcoin/bitcoin#14275 | PR14275]]. This is slighly adapted to not reduce large fork coverage but allow the test to pass on windows. Test Plan: ./test/functional/test_runner.py feature_notifications Ran on Linux, windows (depends on D5964) and OSX for sanity. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D5966
…nt files to avoid race condition in feature_notifications.py 67654b6 tests: write the notification to different files to avoid race condition (Chun Kuan Lee) Pull request description: This PR change the behavior that `feature_notifications.py` would write to different files instead of writing to the same file to avoid race condition. Tree-SHA512: 78406167cc6a3f570134b0ee76d2be1440bc1498cd7b1be72fae16d0ab86950e26ef3bf6008796016e5418231400c6492f0e062909dd882646541ecb7a70fb30
…nt files to avoid race condition in feature_notifications.py 67654b6 tests: write the notification to different files to avoid race condition (Chun Kuan Lee) Pull request description: This PR change the behavior that `feature_notifications.py` would write to different files instead of writing to the same file to avoid race condition. Tree-SHA512: 78406167cc6a3f570134b0ee76d2be1440bc1498cd7b1be72fae16d0ab86950e26ef3bf6008796016e5418231400c6492f0e062909dd882646541ecb7a70fb30
This PR change the behavior that
feature_notifications.py
would write to different files instead of writing to the same file to avoid race condition.