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

Fix a race condition in test_multi_threaded_dates #171

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

sepeth
Copy link
Contributor

@sepeth sepeth commented Sep 2, 2024

Hi there,

This fixes a race condition in test_multi_threaded_dates.

If a worker thread takes less than 500 ms, this test fails due to missing MUST_BE_PRINTED lines. This is because the main thread sleeps 500 ms before setting a new spec for trace!.

XXXXX [2024-09-02 09:55:33.010986 +00:00] T["test_multi_threaded_dates"] INFO [tests/test_multi_threaded_dates.rs:41] create many log lines with a considerable number of threads, verify the log
XXXXX [2024-09-02 09:55:33.514113 +00:00] T["test_multi_threaded_dates"] INFO [tests/test_utils.rs:81] Task executed in 503 ms.
test test_multi_threaded_dates ... FAILED

failures:

---- test_multi_threaded_dates stdout ----
thread 'test_multi_threaded_dates' panicked at tests/test_multi_threaded_dates.rs:139:5:
assertion `left == right` failed
  left: 100003
 right: 100008

There is a race condition that can potentially happen but it is a lot less likely: if all of the worker threads finishes before the main thread configures the trace!. This is a lot less likely because the condvar will notify the main thread before the workers start doing IO loop, and main thread no longer sleeps once all worker threads initialized.

If a worker thread takes less than 500 ms, this test fails due to
missing MUST_BE_PRINTED lines. This is because the main thread sleeps
500 ms before setting a new spec for trace!.

```
XXXXX [2024-09-02 09:55:33.010986 +00:00] T["test_multi_threaded_dates"] INFO [tests/test_multi_threaded_dates.rs:41] create many log lines with a considerable number of threads, verify the log
XXXXX [2024-09-02 09:55:33.514113 +00:00] T["test_multi_threaded_dates"] INFO [tests/test_utils.rs:81] Task executed in 503 ms.
test test_multi_threaded_dates ... FAILED

failures:

---- test_multi_threaded_dates stdout ----
thread 'test_multi_threaded_dates' panicked at tests/test_multi_threaded_dates.rs:139:5:
assertion `left == right` failed
  left: 100003
 right: 100008
```
@emabee emabee merged commit 18f6b24 into emabee:master Sep 13, 2024
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