Revert "toy around with different ways to shut down"

This reverts commit d359d88f51.
This commit is contained in:
Christian Schwarz
2024-07-02 17:33:22 +00:00
parent d359d88f51
commit 45035ca950
4 changed files with 8 additions and 85 deletions

View File

@@ -1,6 +1,5 @@
use std::pin::Pin;
use anyhow::Context;
use futures::SinkExt;
use pageserver_api::{
models::{
@@ -66,11 +65,10 @@ impl Client {
let Client {
cancel_on_client_drop,
conn_task,
client,
client: _,
} = self;
Ok(PagestreamClient {
copy_both: Box::pin(copy_both),
client,
conn_task,
cancel_on_client_drop,
})
@@ -95,28 +93,11 @@ impl Client {
}
Ok(self.client.copy_out(&args.join(" ")).await?)
}
pub async fn shutdown(self) -> anyhow::Result<()> {
let Self {
client,
cancel_on_client_drop,
conn_task,
} = self;
drop(client); // this sends Terminate message(?)
conn_task
.await
.context("wait for network communications to finish cleanly")?;
drop(cancel_on_client_drop);
Ok(())
}
}
/// Create using [`Client::pagestream`].
pub struct PagestreamClient {
copy_both: Pin<Box<tokio_postgres::CopyBothDuplex<bytes::Bytes>>>,
/// Must not use this until copy_both has been shut down.
client: tokio_postgres::Client,
cancel_on_client_drop: Option<tokio_util::sync::DropGuard>,
conn_task: JoinHandle<()>,
}
@@ -127,11 +108,10 @@ pub struct RelTagBlockNo {
}
impl PagestreamClient {
pub async fn shutdown(self) -> anyhow::Result<Client> {
pub async fn shutdown(self) {
let Self {
mut copy_both,
client,
cancel_on_client_drop,
copy_both,
cancel_on_client_drop: cancel_conn_task,
conn_task,
} = self;
// The `copy_both` contains internal channel sender, the receiver of which is polled by `conn_task`.
@@ -151,13 +131,9 @@ impl PagestreamClient {
//
// NB: page_service doesn't have a use case to exit the `pagestream` mode currently.
// => https://github.com/neondatabase/neon/issues/6390
let _: () = copy_both.close().await.unwrap();
Ok(Client {
client,
cancel_on_client_drop,
conn_task,
})
let _ = cancel_conn_task.unwrap();
conn_task.await.unwrap();
drop(copy_both);
}
pub async fn getpage(