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

Fixes race in detection of ClickHouse port from log file #139

Merged
merged 5 commits into from
Jun 30, 2021

Conversation

bnaecker
Copy link
Collaborator

The original implementation of this code searched the ClickHouse log
file for the port number, but only until EOF. There's a race here, as
the ClickHouse subprocess may not write the port number by the time the
reading code starts parsing the log -- the reader hits EOF before the
port is written, and bails.

This commit adds a loop for reading the log file that ignores EOF,
sleeping for a time. This is run with a timeout to avoid an infinite
loop. Regression tests have also been added.

The original implementation of this code searched the ClickHouse log
file for the port number, but only until EOF. There's a race here, as
the ClickHouse subprocess may not write the port number by the time the
reading code starts parsing the log -- the reader hits EOF before the
port is written, and bails.

This commit adds a loop for reading the log file that ignores EOF,
sleeping for a time. This is run with a timeout to avoid an infinite
loop. Regression tests have also been added.
@bnaecker
Copy link
Collaborator Author

This should close #130

Uses `tokio`'s utilities for pausing and advancing time explicitly to
run the tests for parsing ClickHouse's log file for a port number. These
can be used to avoid long sleeps, as we can directly advance time
"beyond" those points, by an amount appropriate for the test
@bnaecker
Copy link
Collaborator Author

@smklein @andrewjstone New commit up that advances time explicitly to avoid "real" sleeps. Thanks Sean for the tip, let me know if y'all have other thoughts!

omicron-common/Cargo.toml Outdated Show resolved Hide resolved
omicron-common/src/dev/clickhouse.rs Outdated Show resolved Hide resolved
omicron-common/src/dev/clickhouse.rs Outdated Show resolved Hide resolved
.github/workflows/rust.yml Outdated Show resolved Hide resolved
Copy link
Collaborator

@smklein smklein left a comment

Choose a reason for hiding this comment

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

TIL about cargo's resolver versions.

LGTM!

@bnaecker bnaecker merged commit 6e51d65 into main Jun 30, 2021
@bnaecker bnaecker deleted the fix/where-are-you-clickhouse-port branch June 30, 2021 15:19
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.

4 participants