@@ -27,7 +27,7 @@ use spacetimedb_datastore::db_metrics::data_size::DATA_SIZE_METRICS;
27
27
use spacetimedb_datastore:: db_metrics:: DB_METRICS ;
28
28
use spacetimedb_datastore:: traits:: Program ;
29
29
use spacetimedb_durability:: { self as durability, TxOffset } ;
30
- use spacetimedb_lib:: { hash_bytes, ConnectionId , Identity } ;
30
+ use spacetimedb_lib:: { hash_bytes, Identity } ;
31
31
use spacetimedb_paths:: server:: { ReplicaDir , ServerDataDir } ;
32
32
use spacetimedb_paths:: FromPathUnchecked ;
33
33
use spacetimedb_sats:: hash:: Hash ;
@@ -841,48 +841,35 @@ impl Host {
841
841
scheduler_starter,
842
842
} = launched;
843
843
844
- Self :: handle_dangling_clients (
845
- & replica_ctx. database_identity ,
846
- & module_host,
847
- connected_clients. into_iter ( ) ,
848
- )
849
- . await ?;
850
-
851
- scheduler_starter. start ( & module_host) ?;
852
- let disk_metrics_recorder_task = tokio:: spawn ( metric_reporter ( replica_ctx. clone ( ) ) ) . abort_handle ( ) ;
853
-
854
- Ok ( Host {
855
- module : watch:: Sender :: new ( module_host) ,
856
- replica_ctx,
857
- scheduler,
858
- disk_metrics_recorder_task,
859
- tx_metrics_recorder_task,
860
- } )
861
- }
862
-
863
- async fn handle_dangling_clients (
864
- database_identity : & Identity ,
865
- module_host : & ModuleHost ,
866
- connected_clients : impl Iterator < Item = ( Identity , ConnectionId ) > ,
867
- ) -> anyhow:: Result < ( ) > {
844
+ // Disconnect dangling clients.
868
845
for ( identity, connection_id) in connected_clients {
869
846
module_host
870
847
. call_identity_disconnected ( identity, connection_id)
871
848
. await
872
849
. with_context ( || {
873
850
format ! (
874
851
"Error calling disconnect for {} {} on {}" ,
875
- identity, connection_id, database_identity
852
+ identity, connection_id, replica_ctx . database_identity
876
853
)
877
854
} ) ?;
878
855
}
879
-
880
856
// We should have no clients left, but we do this just in case.
881
857
// This should only matter if we crashed with something in st_client_credentials,
882
858
// then restarted with an older version of the code that doesn't use st_client_credentials.
883
859
// That case would cause some permanently dangling st_client_credentials.
884
860
// Since we have no clients on startup, this should be safe to do regardless.
885
- module_host. clear_all_clients ( ) . await
861
+ module_host. clear_all_clients ( ) . await ?;
862
+
863
+ scheduler_starter. start ( & module_host) ?;
864
+ let disk_metrics_recorder_task = tokio:: spawn ( metric_reporter ( replica_ctx. clone ( ) ) ) . abort_handle ( ) ;
865
+
866
+ Ok ( Host {
867
+ module : watch:: Sender :: new ( module_host) ,
868
+ replica_ctx,
869
+ scheduler,
870
+ disk_metrics_recorder_task,
871
+ tx_metrics_recorder_task,
872
+ } )
886
873
}
887
874
888
875
/// Construct an in-memory instance of `database` running `program`,
0 commit comments