mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-13 08:36:54 +00:00
fix: return 503 on lock contention instead of 500 (#3274)
* fix(ecstore): skip hidden metadata in walk limit * fix(ecstore): match walk limit to visible versions * fix(ecstore): avoid decoding all versions for limit * fix: return 503 on lock contention instead of 500 When concurrent PUTs to the same key contend for the namespace write lock, lock timeout and conflict errors were wrapped as StorageError::other(...) → StorageError::Io(...), which fell through to S3ErrorCode::InternalError (500) in the error mapping. Only QuorumNotReached was correctly mapped to ServiceUnavailable (503); all other lock errors (Timeout, AlreadyLocked, etc.) became 500. Fix: map_namespace_lock_error now returns StorageError::Lock(err) for non-quorum lock errors, and StorageError::Lock is mapped to S3ErrorCode::ServiceUnavailable in the HTTP error conversion. Affected paths: - crates/ecstore/src/set_disk/lock.rs - crates/ecstore/src/store/object.rs - crates/ecstore/src/store/bucket.rs (make_bucket, delete_bucket) - rustfs/src/app/object_usecase.rs (copy_object) Regression test: test_concurrent_put_same_key_never_returns_500 * test: fail on unexpected lock contention errors --------- Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
@@ -67,10 +67,7 @@ impl SetDisks {
|
||||
achieved,
|
||||
}
|
||||
}
|
||||
other => StorageError::other(format!(
|
||||
"Failed to acquire {mode} lock: {}",
|
||||
self.format_lock_error_from_error(bucket, object, mode, &other)
|
||||
)),
|
||||
other => StorageError::Lock(other),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ impl ECStore {
|
||||
achieved,
|
||||
}
|
||||
}
|
||||
other => StorageError::other(format!("make_bucket: failed to acquire write lock on {bucket}: {other}")),
|
||||
other => StorageError::Lock(other),
|
||||
})?,
|
||||
)
|
||||
} else {
|
||||
@@ -185,7 +185,7 @@ impl ECStore {
|
||||
achieved,
|
||||
}
|
||||
}
|
||||
other => StorageError::other(format!("delete_bucket: failed to acquire write lock on {bucket}: {other}")),
|
||||
other => StorageError::Lock(other),
|
||||
})?,
|
||||
)
|
||||
} else {
|
||||
|
||||
@@ -243,7 +243,7 @@ impl ECStore {
|
||||
required,
|
||||
achieved,
|
||||
},
|
||||
other => StorageError::other(format!("Failed to acquire {mode} lock on {bucket}/{object}: {other}")),
|
||||
other => StorageError::Lock(other),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user