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:: { info , Level , Span } ;
24
24
use tracing_indicatif:: { span_ext:: IndicatifSpanExt , style:: ProgressStyle } ;
25
25
use ulid:: Ulid ;
26
26
use uuid:: Uuid ;
@@ -223,6 +223,8 @@ async fn migrate_users(
223
223
mut state : MigrationState ,
224
224
rng : & mut impl RngCore ,
225
225
) -> Result < ( MasWriter , MigrationState ) , Error > {
226
+ let start = Instant :: now ( ) ;
227
+
226
228
let span = Span :: current ( ) ;
227
229
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
228
230
span. pb_set_length ( count_hint as u64 ) ;
@@ -278,6 +280,11 @@ async fn migrate_users(
278
280
. await
279
281
. into_mas ( "writing passwords" ) ?;
280
282
283
+ info ! (
284
+ "users migrated in {:.1}s" ,
285
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
286
+ ) ;
287
+
281
288
Ok ( ( mas, state) )
282
289
}
283
290
@@ -289,6 +296,8 @@ async fn migrate_threepids(
289
296
rng : & mut impl RngCore ,
290
297
state : MigrationState ,
291
298
) -> Result < ( MasWriter , MigrationState ) , Error > {
299
+ let start = Instant :: now ( ) ;
300
+
292
301
let span = Span :: current ( ) ;
293
302
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
294
303
span. pb_set_length ( count_hint as u64 ) ;
@@ -367,6 +376,11 @@ async fn migrate_threepids(
367
376
. await
368
377
. into_mas ( "writing unsupported threepids" ) ?;
369
378
379
+ info ! (
380
+ "third-party IDs migrated in {:.1}s" ,
381
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
382
+ ) ;
383
+
370
384
Ok ( ( mas, state) )
371
385
}
372
386
@@ -382,6 +396,7 @@ async fn migrate_external_ids(
382
396
rng : & mut impl RngCore ,
383
397
state : MigrationState ,
384
398
) -> Result < ( MasWriter , MigrationState ) , Error > {
399
+ let start = Instant :: now ( ) ;
385
400
let span = Span :: current ( ) ;
386
401
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
387
402
span. pb_set_length ( count_hint as u64 ) ;
@@ -442,7 +457,12 @@ async fn migrate_external_ids(
442
457
write_buffer
443
458
. finish ( & mut mas)
444
459
. await
445
- . into_mas ( "writing threepids" ) ?;
460
+ . into_mas ( "writing upstream links" ) ?;
461
+
462
+ info ! (
463
+ "upstream links (external IDs) migrated in {:.1}s" ,
464
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
465
+ ) ;
446
466
447
467
Ok ( ( mas, state) )
448
468
}
@@ -464,6 +484,8 @@ async fn migrate_devices(
464
484
rng : & mut impl RngCore ,
465
485
mut state : MigrationState ,
466
486
) -> Result < ( MasWriter , MigrationState ) , Error > {
487
+ let start = Instant :: now ( ) ;
488
+
467
489
let span = Span :: current ( ) ;
468
490
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
469
491
span. pb_set_length ( count_hint as u64 ) ;
@@ -551,6 +573,11 @@ async fn migrate_devices(
551
573
. await
552
574
. into_mas ( "writing compat sessions" ) ?;
553
575
576
+ info ! (
577
+ "devices migrated in {:.1}s" ,
578
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
579
+ ) ;
580
+
554
581
Ok ( ( mas, state) )
555
582
}
556
583
@@ -566,6 +593,8 @@ async fn migrate_unrefreshable_access_tokens(
566
593
rng : & mut impl RngCore ,
567
594
mut state : MigrationState ,
568
595
) -> Result < ( MasWriter , MigrationState ) , Error > {
596
+ let start = Instant :: now ( ) ;
597
+
569
598
let span = Span :: current ( ) ;
570
599
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
571
600
span. pb_set_length ( count_hint as u64 ) ;
@@ -670,6 +699,11 @@ async fn migrate_unrefreshable_access_tokens(
670
699
. await
671
700
. into_mas ( "writing deviceless compat sessions" ) ?;
672
701
702
+ info ! (
703
+ "non-refreshable access tokens migrated in {:.1}s" ,
704
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
705
+ ) ;
706
+
673
707
Ok ( ( mas, state) )
674
708
}
675
709
@@ -685,6 +719,8 @@ async fn migrate_refreshable_token_pairs(
685
719
rng : & mut impl RngCore ,
686
720
mut state : MigrationState ,
687
721
) -> Result < ( MasWriter , MigrationState ) , Error > {
722
+ let start = Instant :: now ( ) ;
723
+
688
724
let span = Span :: current ( ) ;
689
725
span. pb_set_style ( & ProgressStyle :: default_bar ( ) ) ;
690
726
span. pb_set_length ( count_hint as u64 ) ;
@@ -777,6 +813,11 @@ async fn migrate_refreshable_token_pairs(
777
813
. await
778
814
. into_mas ( "writing compat refresh tokens" ) ?;
779
815
816
+ info ! (
817
+ "refreshable token pairs migrated in {:.1}s" ,
818
+ Instant :: now( ) . duration_since( start) . as_secs_f64( )
819
+ ) ;
820
+
780
821
Ok ( ( mas, state) )
781
822
}
782
823
0 commit comments