11
11
//! This module does not implement any of the safety checks that should be run
12
12
//! *before* the migration.
13
13
14
- use std:: { collections:: HashMap , pin:: pin} ;
14
+ use std:: { collections:: HashMap , pin:: pin, time :: Instant } ;
15
15
16
16
use chrono:: { DateTime , Utc } ;
17
17
use compact_str:: CompactString ;
@@ -20,7 +20,7 @@ use mas_storage::Clock;
20
20
use rand:: RngCore ;
21
21
use thiserror:: Error ;
22
22
use thiserror_ext:: ContextInto ;
23
- use tracing:: { Level , Span } ;
23
+ use tracing:: { Level , Span , info } ;
24
24
use tracing_indicatif:: { span_ext:: IndicatifSpanExt , style:: ProgressStyle } ;
25
25
use ulid:: Ulid ;
26
26
use uuid:: Uuid ;
@@ -230,6 +230,8 @@ async fn migrate_users(
230
230
mut state : MigrationState ,
231
231
rng : & mut impl RngCore ,
232
232
) -> Result < ( MasWriter , MigrationState ) , Error > {
233
+ let start = Instant :: now ( ) ;
234
+
233
235
let span = Span :: current ( ) ;
234
236
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
235
237
span. pb_set_length ( count_hint as u64 ) ;
@@ -299,6 +301,11 @@ async fn migrate_users(
299
301
. await
300
302
. into_mas ( "writing passwords" ) ?;
301
303
304
+ info ! (
305
+ "users migrated in {:.1}s" ,
306
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
307
+ ) ;
308
+
302
309
Ok ( ( mas, state) )
303
310
}
304
311
@@ -310,6 +317,8 @@ async fn migrate_threepids(
310
317
rng : & mut impl RngCore ,
311
318
state : MigrationState ,
312
319
) -> Result < ( MasWriter , MigrationState ) , Error > {
320
+ let start = Instant :: now ( ) ;
321
+
313
322
let span = Span :: current ( ) ;
314
323
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
315
324
span. pb_set_length ( count_hint as u64 ) ;
@@ -385,6 +394,11 @@ async fn migrate_threepids(
385
394
. await
386
395
. into_mas ( "writing unsupported threepids" ) ?;
387
396
397
+ info ! (
398
+ "third-party IDs migrated in {:.1}s" ,
399
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
400
+ ) ;
401
+
388
402
Ok ( ( mas, state) )
389
403
}
390
404
@@ -400,6 +414,7 @@ async fn migrate_external_ids(
400
414
rng : & mut impl RngCore ,
401
415
state : MigrationState ,
402
416
) -> Result < ( MasWriter , MigrationState ) , Error > {
417
+ let start = Instant :: now ( ) ;
403
418
let span = Span :: current ( ) ;
404
419
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
405
420
span. pb_set_length ( count_hint as u64 ) ;
@@ -461,7 +476,12 @@ async fn migrate_external_ids(
461
476
write_buffer
462
477
. finish ( & mut mas)
463
478
. await
464
- . into_mas ( "writing threepids" ) ?;
479
+ . into_mas ( "writing upstream links" ) ?;
480
+
481
+ info ! (
482
+ "upstream links (external IDs) migrated in {:.1}s" ,
483
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
484
+ ) ;
465
485
466
486
Ok ( ( mas, state) )
467
487
}
@@ -483,6 +503,8 @@ async fn migrate_devices(
483
503
rng : & mut impl RngCore ,
484
504
mut state : MigrationState ,
485
505
) -> Result < ( MasWriter , MigrationState ) , Error > {
506
+ let start = Instant :: now ( ) ;
507
+
486
508
let span = Span :: current ( ) ;
487
509
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
488
510
span. pb_set_length ( count_hint as u64 ) ;
@@ -572,6 +594,11 @@ async fn migrate_devices(
572
594
. await
573
595
. into_mas ( "writing compat sessions" ) ?;
574
596
597
+ info ! (
598
+ "devices migrated in {:.1}s" ,
599
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
600
+ ) ;
601
+
575
602
Ok ( ( mas, state) )
576
603
}
577
604
@@ -587,6 +614,8 @@ async fn migrate_unrefreshable_access_tokens(
587
614
rng : & mut impl RngCore ,
588
615
mut state : MigrationState ,
589
616
) -> Result < ( MasWriter , MigrationState ) , Error > {
617
+ let start = Instant :: now ( ) ;
618
+
590
619
let span = Span :: current ( ) ;
591
620
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
592
621
span. pb_set_length ( count_hint as u64 ) ;
@@ -691,6 +720,11 @@ async fn migrate_unrefreshable_access_tokens(
691
720
. await
692
721
. into_mas ( "writing deviceless compat sessions" ) ?;
693
722
723
+ info ! (
724
+ "non-refreshable access tokens migrated in {:.1}s" ,
725
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
726
+ ) ;
727
+
694
728
Ok ( ( mas, state) )
695
729
}
696
730
@@ -706,6 +740,8 @@ async fn migrate_refreshable_token_pairs(
706
740
rng : & mut impl RngCore ,
707
741
mut state : MigrationState ,
708
742
) -> Result < ( MasWriter , MigrationState ) , Error > {
743
+ let start = Instant :: now ( ) ;
744
+
709
745
let span = Span :: current ( ) ;
710
746
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
711
747
span. pb_set_length ( count_hint as u64 ) ;
@@ -798,6 +834,11 @@ async fn migrate_refreshable_token_pairs(
798
834
. await
799
835
. into_mas ( "writing compat refresh tokens" ) ?;
800
836
837
+ info ! (
838
+ "refreshable token pairs migrated in {:.1}s" ,
839
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
840
+ ) ;
841
+
801
842
Ok ( ( mas, state) )
802
843
}
803
844
0 commit comments