-
Notifications
You must be signed in to change notification settings - Fork 52
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
feat: add shutdown
method to AsyncDB
DB
and Runner
#250
Conversation
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
sqllogictest-engines/src/postgres.rs
Outdated
pub fn pg_client(&self) -> &tokio_postgres::Client { | ||
&self.client | ||
pub fn client(&self) -> &tokio_postgres::Client { | ||
&self.conn.as_ref().expect("fuck").0 |
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.
?
sqllogictest/src/runner.rs
Outdated
impl<D: AsyncDB, M: MakeConnection<Conn = D>> Drop for Runner<D, M> { | ||
fn drop(&mut self) { | ||
tracing::debug!("shutting down runner..."); | ||
block_on(self.conn.shutdown_all()); | ||
} | ||
} |
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.
Would block_on
in drop
be problematic? (If not, why don't we simply do it in impl Drop for Postgres
without introducing a separate shutdown
?
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 is a good point... 😕
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.
Updated to always let the caller handle shutdown
.
Nice catch 👍 |
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
unfortunately we need to bump the version :( |
Signed-off-by: Bugen Zhao <[email protected]>
shutdown
method to AsyncDB
shutdown
method to AsyncDB
DB
and Runner
Signed-off-by: Bugen Zhao <[email protected]>
4c22c2a
to
018e24c
Compare
Changes
Add
shutdown
method toAsyncDB
. Implement it for all engines. Adopt it in binary.Motivation
Previously we have a
Drop
impl forPostgres
which directly aborts the background connection. This is not good as there's no chance for the pgwire protocol to gracefully shutdown itself. As a result, we seefailed to read message: unexpected end of file
every time a test case (file) completes in the server side.Simply removing this
Drop
impl and letting the connection run to completion in the background resolves this issue. However, let's get one step further and propose a general design to all kinds of database engines by manually specifying and calling theshutdown
method.Signed-off-by: Bugen Zhao [email protected]