14
14
use std:: {
15
15
collections:: { HashMap , HashSet } ,
16
16
pin:: pin,
17
+ time:: Instant ,
17
18
} ;
18
19
19
20
use chrono:: { DateTime , Utc } ;
@@ -23,7 +24,7 @@ use mas_storage::Clock;
23
24
use rand:: RngCore ;
24
25
use thiserror:: Error ;
25
26
use thiserror_ext:: ContextInto ;
26
- use tracing:: { Level , Span } ;
27
+ use tracing:: { info , Level , Span } ;
27
28
use tracing_indicatif:: { span_ext:: IndicatifSpanExt , style:: ProgressStyle } ;
28
29
use ulid:: Ulid ;
29
30
use uuid:: Uuid ;
@@ -246,6 +247,8 @@ async fn migrate_users(
246
247
server_name : & str ,
247
248
rng : & mut impl RngCore ,
248
249
) -> Result < UsersMigrated , Error > {
250
+ let start = Instant :: now ( ) ;
251
+
249
252
let span = Span :: current ( ) ;
250
253
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
251
254
span. pb_set_length ( user_count_hint as u64 ) ;
@@ -292,6 +295,11 @@ async fn migrate_users(
292
295
. await
293
296
. into_mas ( "writing passwords" ) ?;
294
297
298
+ info ! (
299
+ "users migrated in {:.1}s" ,
300
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
301
+ ) ;
302
+
295
303
Ok ( UsersMigrated {
296
304
user_localparts_to_uuid,
297
305
synapse_admins,
@@ -307,6 +315,8 @@ async fn migrate_threepids(
307
315
rng : & mut impl RngCore ,
308
316
user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
309
317
) -> Result < ( ) , Error > {
318
+ let start = Instant :: now ( ) ;
319
+
310
320
let span = Span :: current ( ) ;
311
321
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
312
322
span. pb_set_length ( count_hint) ;
@@ -386,6 +396,11 @@ async fn migrate_threepids(
386
396
. await
387
397
. into_mas ( "writing unsupported threepids" ) ?;
388
398
399
+ info ! (
400
+ "third-party IDs migrated in {:.1}s" ,
401
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
402
+ ) ;
403
+
389
404
Ok ( ( ) )
390
405
}
391
406
@@ -403,6 +418,8 @@ async fn migrate_external_ids(
403
418
user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
404
419
provider_id_mapping : & HashMap < String , Uuid > ,
405
420
) -> Result < ( ) , Error > {
421
+ let start = Instant :: now ( ) ;
422
+
406
423
let span = Span :: current ( ) ;
407
424
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
408
425
span. pb_set_length ( count_hint) ;
@@ -464,7 +481,12 @@ async fn migrate_external_ids(
464
481
write_buffer
465
482
. finish ( mas)
466
483
. await
467
- . into_mas ( "writing threepids" ) ?;
484
+ . into_mas ( "writing upstream links" ) ?;
485
+
486
+ info ! (
487
+ "upstream links (external IDs) migrated in {:.1}s" ,
488
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
489
+ ) ;
468
490
469
491
Ok ( ( ) )
470
492
}
@@ -489,6 +511,8 @@ async fn migrate_devices(
489
511
devices : & mut HashMap < ( Uuid , CompactString ) , Uuid > ,
490
512
synapse_admins : & HashSet < Uuid > ,
491
513
) -> Result < ( ) , Error > {
514
+ let start = Instant :: now ( ) ;
515
+
492
516
let span = Span :: current ( ) ;
493
517
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
494
518
span. pb_set_length ( count_hint) ;
@@ -573,6 +597,11 @@ async fn migrate_devices(
573
597
. await
574
598
. into_mas ( "writing compat sessions" ) ?;
575
599
600
+ info ! (
601
+ "devices migrated in {:.1}s" ,
602
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
603
+ ) ;
604
+
576
605
Ok ( ( ) )
577
606
}
578
607
@@ -590,6 +619,8 @@ async fn migrate_unrefreshable_access_tokens(
590
619
user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
591
620
devices : & mut HashMap < ( Uuid , CompactString ) , Uuid > ,
592
621
) -> Result < ( ) , Error > {
622
+ let start = Instant :: now ( ) ;
623
+
593
624
let span = Span :: current ( ) ;
594
625
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
595
626
span. pb_set_length ( count_hint) ;
@@ -691,6 +722,11 @@ async fn migrate_unrefreshable_access_tokens(
691
722
. await
692
723
. into_mas ( "writing deviceless compat sessions" ) ?;
693
724
725
+ info ! (
726
+ "non-refreshable access tokens migrated in {:.1}s" ,
727
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
728
+ ) ;
729
+
694
730
Ok ( ( ) )
695
731
}
696
732
@@ -708,6 +744,8 @@ async fn migrate_refreshable_token_pairs(
708
744
user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
709
745
devices : & mut HashMap < ( Uuid , CompactString ) , Uuid > ,
710
746
) -> Result < ( ) , Error > {
747
+ let start = Instant :: now ( ) ;
748
+
711
749
let span = Span :: current ( ) ;
712
750
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
713
751
span. pb_set_length ( count_hint) ;
@@ -797,6 +835,11 @@ async fn migrate_refreshable_token_pairs(
797
835
. await
798
836
. into_mas ( "writing compat refresh tokens" ) ?;
799
837
838
+ info ! (
839
+ "refreshable token pairs migrated in {:.1}s" ,
840
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
841
+ ) ;
842
+
800
843
Ok ( ( ) )
801
844
}
802
845
0 commit comments