mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-29 16:37:07 +00:00
fix(table-catalog): classify storage quorum as unavailable (#6531)
Co-authored-by: Henry Guo <marshawcoco@users.noreply.github.com>
This commit is contained in:
@@ -383,6 +383,9 @@ fn is_missing_storage_error(err: &StorageError) -> bool {
|
||||
}
|
||||
|
||||
fn storage_error_to_catalog(action: &str, err: StorageError) -> TableCatalogStoreError {
|
||||
if err.is_quorum_error() {
|
||||
return TableCatalogStoreError::Unavailable(format!("{action}: {err}"));
|
||||
}
|
||||
match err {
|
||||
StorageError::ObjectNotFound(bucket, object) => TableCatalogStoreError::NotFound(format!("{action}: {bucket}/{object}")),
|
||||
StorageError::BucketNotFound(bucket) => TableCatalogStoreError::NotFound(format!("{action}: bucket {bucket}")),
|
||||
|
||||
@@ -59,6 +59,33 @@ fn catalog_lock_authority_failures_are_typed_as_unavailable() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn catalog_storage_quorum_failures_are_typed_as_unavailable() {
|
||||
for error in [
|
||||
StorageError::ErasureReadQuorum,
|
||||
StorageError::ErasureWriteQuorum,
|
||||
StorageError::InsufficientReadQuorum(".rustfs.sys".to_string(), "snapshot.json".to_string()),
|
||||
StorageError::InsufficientWriteQuorum(".rustfs.sys".to_string(), "snapshot.json".to_string()),
|
||||
StorageError::NamespaceLockQuorumUnavailable {
|
||||
mode: "read",
|
||||
bucket: ".rustfs.sys".to_string(),
|
||||
object: "s3tables/catalog/strong-backing/snapshot.json".to_string(),
|
||||
required: 2,
|
||||
achieved: 0,
|
||||
},
|
||||
] {
|
||||
assert_matches!(
|
||||
storage_error_to_catalog("stat catalog object", error),
|
||||
TableCatalogStoreError::Unavailable(_)
|
||||
);
|
||||
}
|
||||
|
||||
assert_matches!(
|
||||
storage_error_to_catalog("stat catalog object", StorageError::FileCorrupt),
|
||||
TableCatalogStoreError::Internal(_)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reserved_table_object_key_matches_exact_prefix_and_children_only() {
|
||||
assert!(is_reserved_table_object_key(".rustfs-table"));
|
||||
|
||||
Reference in New Issue
Block a user