@@ -1118,6 +1118,26 @@ enum ImageLayerCreationOutcome {
1118
1118
Skip ,
1119
1119
}
1120
1120
1121
+ enum RepartitionError {
1122
+ Other ( anyhow:: Error ) ,
1123
+ CollectKeyspace ( CollectKeySpaceError ) ,
1124
+ }
1125
+
1126
+ impl RepartitionError {
1127
+ fn is_cancel ( & self ) -> bool {
1128
+ match self {
1129
+ RepartitionError :: Other ( _) => false ,
1130
+ RepartitionError :: CollectKeyspace ( e) => e. is_cancel ( ) ,
1131
+ }
1132
+ }
1133
+ fn into_anyhow ( self ) -> anyhow:: Error {
1134
+ match self {
1135
+ RepartitionError :: Other ( e) => e,
1136
+ RepartitionError :: CollectKeyspace ( e) => e. into_anyhow ( ) ,
1137
+ }
1138
+ }
1139
+ }
1140
+
1121
1141
/// Public interface functions
1122
1142
impl Timeline {
1123
1143
/// Get the LSN where this branch was created
@@ -4992,7 +5012,7 @@ impl Timeline {
4992
5012
ctx,
4993
5013
)
4994
5014
. await
4995
- . map_err ( |e| FlushLayerError :: from_anyhow ( self , e. into ( ) ) ) ?;
5015
+ . map_err ( |e| FlushLayerError :: from_anyhow ( self , e. into_anyhow ( ) ) ) ?;
4996
5016
4997
5017
if self . cancel . is_cancelled ( ) {
4998
5018
return Err ( FlushLayerError :: Cancelled ) ;
@@ -5242,18 +5262,18 @@ impl Timeline {
5242
5262
partition_size : u64 ,
5243
5263
flags : EnumSet < CompactFlags > ,
5244
5264
ctx : & RequestContext ,
5245
- ) -> Result < ( ( KeyPartitioning , SparseKeyPartitioning ) , Lsn ) , CompactionError > {
5265
+ ) -> Result < ( ( KeyPartitioning , SparseKeyPartitioning ) , Lsn ) , RepartitionError > {
5246
5266
let Ok ( mut guard) = self . partitioning . try_write_guard ( ) else {
5247
5267
// NB: there are two callers, one is the compaction task, of which there is only one per struct Tenant and hence Timeline.
5248
5268
// The other is the initdb optimization in flush_frozen_layer, used by `boostrap_timeline`, which runs before `.activate()`
5249
5269
// and hence before the compaction task starts.
5250
- return Err ( CompactionError :: Other ( anyhow ! (
5270
+ return Err ( RepartitionError :: Other ( anyhow ! (
5251
5271
"repartition() called concurrently"
5252
5272
) ) ) ;
5253
5273
} ;
5254
5274
let ( ( dense_partition, sparse_partition) , partition_lsn) = & * guard. read ( ) ;
5255
5275
if lsn < * partition_lsn {
5256
- return Err ( CompactionError :: Other ( anyhow ! (
5276
+ return Err ( RepartitionError :: Other ( anyhow ! (
5257
5277
"repartition() called with LSN going backwards, this should not happen"
5258
5278
) ) ) ;
5259
5279
}
@@ -5277,23 +5297,7 @@ impl Timeline {
5277
5297
let ( dense_ks, sparse_ks) = self
5278
5298
. collect_keyspace ( lsn, ctx)
5279
5299
. await
5280
- . inspect_err ( |e| {
5281
- if matches ! (
5282
- e,
5283
- CollectKeySpaceError :: Decode ( _)
5284
- | CollectKeySpaceError :: PageRead (
5285
- PageReconstructError :: MissingKey ( _) | PageReconstructError :: WalRedo ( _) ,
5286
- )
5287
- ) {
5288
- // Alert on critical errors that indicate data corruption.
5289
- critical_timeline ! (
5290
- self . tenant_shard_id,
5291
- self . timeline_id,
5292
- "could not compact, repartitioning keyspace failed: {e:?}"
5293
- ) ;
5294
- }
5295
- } )
5296
- . map_err ( CompactionError :: from_collect_keyspace) ?;
5300
+ . map_err ( RepartitionError :: CollectKeyspace ) ?;
5297
5301
let dense_partitioning = dense_ks. partition (
5298
5302
& self . shard_identity ,
5299
5303
partition_size,
0 commit comments