-
Notifications
You must be signed in to change notification settings - Fork 55
feat(bin): flush output to stdout before db conn shutdown #262
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
Conversation
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.
Pull Request Overview
This PR ensures that all output is flushed to stdout before shutting down the database connection by refactoring how output is handled. Key changes include:
- Introducing a new Output trait with implementations for Stdout and Vec.
- Refactoring both serial and parallel test runners to use the new Output trait and removing buffer flushing from the caller.
- Adjusting the signature and usage of connect_and_run_test_file accordingly.
Comments suppressed due to low confidence (1)
sqllogictest-bin/src/main.rs:669
- [nitpick] Consider renaming the trait 'Output' to a more descriptive name like 'FlushableOutput' to better convey its purpose.
trait Output: Write {
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
74068a0
to
e117b19
Compare
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
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.
Rest LGTM
sqllogictest-bin/src/main.rs
Outdated
/// to avoid interleaving output from different parallelism. | ||
impl Output for Vec<u8> { | ||
fn finish(&mut self) -> io::Result<()> { | ||
let mut stdout = stdout(); |
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.
This does not guarantee the exclusiveness of the handler?
The std doc says,
Each handle returned is a reference to a shared global buffer whose access is synchronized via a mutex. If you need more explicit control over locking, see the Stdout::lock method.
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.
Good catch. However, it appears that write_all
is not interruptable and we only call it once, so we still won't observe interleaving output. Nonetheless, lock
seems always better.
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
...so that upon cancellation, we get more prompt results from ongoing tests.