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) ;
@@ -556,6 +580,11 @@ async fn migrate_devices(
556
580
. await
557
581
. into_mas ( "writing compat sessions" ) ?;
558
582
583
+ info ! (
584
+ "devices migrated in {:.1}s" ,
585
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
586
+ ) ;
587
+
559
588
Ok ( ( ) )
560
589
}
561
590
@@ -573,6 +602,8 @@ async fn migrate_unrefreshable_access_tokens(
573
602
user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
574
603
devices : & mut HashMap < ( Uuid , CompactString ) , Uuid > ,
575
604
) -> Result < ( ) , Error > {
605
+ let start = Instant :: now ( ) ;
606
+
576
607
let span = Span :: current ( ) ;
577
608
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
578
609
span. pb_set_length ( count_hint) ;
@@ -674,6 +705,11 @@ async fn migrate_unrefreshable_access_tokens(
674
705
. await
675
706
. into_mas ( "writing deviceless compat sessions" ) ?;
676
707
708
+ info ! (
709
+ "non-refreshable access tokens migrated in {:.1}s" ,
710
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
711
+ ) ;
712
+
677
713
Ok ( ( ) )
678
714
}
679
715
@@ -691,6 +727,8 @@ async fn migrate_refreshable_token_pairs(
691
727
user_localparts_to_uuid : & HashMap < CompactString , Uuid > ,
692
728
devices : & mut HashMap < ( Uuid , CompactString ) , Uuid > ,
693
729
) -> Result < ( ) , Error > {
730
+ let start = Instant :: now ( ) ;
731
+
694
732
let span = Span :: current ( ) ;
695
733
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
696
734
span. pb_set_length ( count_hint) ;
@@ -780,6 +818,11 @@ async fn migrate_refreshable_token_pairs(
780
818
. await
781
819
. into_mas ( "writing compat refresh tokens" ) ?;
782
820
821
+ info ! (
822
+ "refreshable token pairs migrated in {:.1}s" ,
823
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
824
+ ) ;
825
+
783
826
Ok ( ( ) )
784
827
}
785
828
0 commit comments