@@ -54,7 +54,8 @@ pub enum ClickHouseError {
5454impl ClickHouseInstance {
5555 /// Start a new ClickHouse server
5656 pub async fn new ( port : u16 ) -> Result < Self , anyhow:: Error > {
57- let data_dir = TempDir :: new ( ) ?;
57+ let data_dir = TempDir :: new ( )
58+ . context ( "failed to create tempdir for ClickHouse data" ) ?;
5859 let log_path = data_dir. path ( ) . join ( "clickhouse-server.log" ) ;
5960 let err_log_path = data_dir. path ( ) . join ( "clickhouse-server.errlog" ) ;
6061 let args = vec ! [
@@ -72,24 +73,32 @@ impl ClickHouseInstance {
7273
7374 let child = tokio:: process:: Command :: new ( "clickhouse" )
7475 . args ( & args)
75- // ClickHouse internall tees its logs to a file, so we throw away std{in,out,err}
76+ // ClickHouse internally tees its logs to a file, so we throw away
77+ // std{in,out,err}
7678 . stdin ( Stdio :: null ( ) )
7779 . stdout ( Stdio :: null ( ) )
7880 . stderr ( Stdio :: null ( ) )
79- // By default ClickHouse forks a child if it's been explicitly requested via the
80- // following environment variable, _or_ if it's not attached to a TTY. Avoid this
81- // behavior, so that we can correctly deliver SIGINT. The "watchdog" masks SIGINT,
82- // meaning we'd have to deliver that to the _child_, which is more complicated.
81+ // By default ClickHouse forks a child if it's been explicitly
82+ // requested via the following environment variable, _or_ if it's
83+ // not attached to a TTY. Avoid this behavior, so that we can
84+ // correctly deliver SIGINT. The "watchdog" masks SIGINT, meaning
85+ // we'd have to deliver that to the _child_, which is more
86+ // complicated.
8387 . env ( "CLICKHOUSE_WATCHDOG_ENABLE" , "0" )
84- . spawn ( ) ?;
88+ . spawn ( )
89+ . with_context ( || {
90+ format ! ( "failed to spawn `clickhouse` (with args: {:?})" , & args)
91+ } ) ?;
8592
86- // Wait for the ClickHouse log file to become available, including the port number.
93+ // Wait for the ClickHouse log file to become available, including the
94+ // port number.
8795 //
88- // We extract the port number from the log-file regardless of whether we know it already,
89- // as this is a more reliable check that the server is up and listening. Previously we only
90- // did this in the case we need to _learn_ the port, which introduces the possibility that
91- // we return from this function successfully, but the server itself is not yet ready to
92- // accept connections.
96+ // We extract the port number from the log-file regardless of whether we
97+ // know it already, as this is a more reliable check that the server is
98+ // up and listening. Previously we only did this in the case we need to
99+ // _learn_ the port, which introduces the possibility that we return
100+ // from this function successfully, but the server itself is not yet
101+ // ready to accept connections.
93102 let data_path = data_dir. path ( ) . to_path_buf ( ) ;
94103 let port = poll:: wait_for_condition (
95104 || async {
@@ -120,7 +129,8 @@ impl ClickHouseInstance {
120129 & Duration :: from_millis ( 500 ) ,
121130 & CLICKHOUSE_TIMEOUT ,
122131 )
123- . await ?;
132+ . await
133+ . context ( "waiting to discover ClickHouse port" ) ?;
124134
125135 Ok ( Self {
126136 data_dir : Some ( data_dir) ,
0 commit comments