mirror of
https://github.com/rustfs/rustfs.git
synced 2026-11-27 10:59:04 +00:00
perf(ecstore): bound PUT rename dialing after write quorum
Share a post-quorum connection deadline across remote rename producers. Unresolved connections can be skipped before dispatch while active mutations drain under the normal namespace owner. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com>
This commit is contained in:
@@ -32,8 +32,8 @@ use crate::disk::{
|
||||
DeleteRecoveryInspection, DeleteRecoveryPage, DeleteRecoveryRpcOperation, DeleteRecoveryRpcReply, DiskAPI, DiskInfo,
|
||||
DiskInfoOptions, DiskLocation, DiskOption, FileInfoVersions, FileReader, FileWriter, GuardedDeleteVersionsPayload,
|
||||
GuardedFileInfoVersions, PartTransactionAction, PoolMetaNativeRecoveryRequest, PoolMetaNativeRecoveryResponse,
|
||||
ReadMultipleReq, ReadMultipleResp, ReadOptions, RenameDataResp, SnapshotLeaseToken, UpdateMetadataOpts, VolumeInfo,
|
||||
WalkDirOptions, batch_read_version_one_by_one,
|
||||
ReadMultipleReq, ReadMultipleResp, ReadOptions, RenameConnectDeadline, RenameDataGuards, RenameDataObservation,
|
||||
RenameDataResp, SnapshotLeaseToken, UpdateMetadataOpts, VolumeInfo, WalkDirOptions, batch_read_version_one_by_one,
|
||||
disk_store::{
|
||||
DEFAULT_RUSTFS_DRIVE_ACTIVE_MONITORING, ENV_RUSTFS_DRIVE_ACTIVE_MONITORING, SKIP_IF_SUCCESS_BEFORE,
|
||||
get_drive_active_check_interval, get_drive_active_check_timeout, get_drive_disk_info_timeout, get_drive_list_dir_timeout,
|
||||
@@ -3313,6 +3313,24 @@ fn validate_decoded_file_info(file_info: &FileInfo) -> Result<()> {
|
||||
file_info.validate_for_metadata_read().map_err(Into::into)
|
||||
}
|
||||
|
||||
async fn connect_for_rename<T>(mut deadline: Option<RenameConnectDeadline>, connect: impl Future<Output = T>) -> Option<T> {
|
||||
let Some(deadline) = deadline.as_mut() else {
|
||||
return Some(connect.await);
|
||||
};
|
||||
tokio::select! {
|
||||
biased;
|
||||
connection = connect => Some(connection),
|
||||
() = async {
|
||||
let at = deadline.wait_for(Option::is_some).await.ok().and_then(|deadline| *deadline);
|
||||
if let Some(at) = at {
|
||||
time::sleep_until(at).await;
|
||||
} else {
|
||||
std::future::pending::<()>().await;
|
||||
}
|
||||
} => None,
|
||||
}
|
||||
}
|
||||
|
||||
impl RemoteDisk {
|
||||
#[tracing::instrument(level = "trace", skip_all)]
|
||||
pub(crate) async fn rename_data_borrowed(
|
||||
@@ -3335,6 +3353,7 @@ impl RemoteDisk {
|
||||
dst_volume: &str,
|
||||
dst_path: &str,
|
||||
items: Vec<RenameBatchClientItem<'_>>,
|
||||
connect_deadline: Option<RenameConnectDeadline>,
|
||||
) -> std::result::Result<RemoteRenameBatchStream, RenameBatchStartError> {
|
||||
if self.rename_admission.is_none() || items.is_empty() || items.len() > 16 {
|
||||
return Err(RenameBatchStartError::NotDispatched(DiskError::UnsupportedDisk));
|
||||
@@ -3358,15 +3377,16 @@ impl RemoteDisk {
|
||||
&self.addr,
|
||||
TonicInterceptor::Signature(gen_tonic_signature_interceptor()),
|
||||
);
|
||||
let mut client = match tokio::time::timeout_at(deadline, routing).await {
|
||||
Ok(Ok(Some(client))) => client,
|
||||
Ok(Ok(None)) => return Err(RenameBatchStartError::UnsupportedBeforeStream),
|
||||
Ok(Err(error)) => {
|
||||
let mut client = match connect_for_rename(connect_deadline, tokio::time::timeout_at(deadline, routing)).await {
|
||||
Some(Ok(Ok(Some(client)))) => client,
|
||||
Some(Ok(Ok(None))) => return Err(RenameBatchStartError::UnsupportedBeforeStream),
|
||||
Some(Ok(Err(error))) => {
|
||||
return Err(RenameBatchStartError::NotDispatched(DiskError::RemoteClientUnavailable(
|
||||
error.to_string(),
|
||||
)));
|
||||
}
|
||||
Err(_) => return Err(RenameBatchStartError::NotDispatched(DiskError::Timeout)),
|
||||
Some(Err(_)) => return Err(RenameBatchStartError::NotDispatched(DiskError::Timeout)),
|
||||
None => return Err(RenameBatchStartError::NotDispatched(DiskError::DiskNotFound)),
|
||||
};
|
||||
let mut request_items = Vec::with_capacity(items.len());
|
||||
for item in items {
|
||||
@@ -3433,7 +3453,6 @@ impl RemoteDisk {
|
||||
Ok(guard.into_stream(response.into_inner(), expected_mask))
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip_all)]
|
||||
pub(crate) async fn rename_data_borrowed_with_fence(
|
||||
&self,
|
||||
src_volume: &str,
|
||||
@@ -3443,6 +3462,36 @@ impl RemoteDisk {
|
||||
dst_path: &str,
|
||||
scanner_publication_lease_token: Option<Uuid>,
|
||||
) -> Result<RenameDataResp> {
|
||||
self.rename_data_observed(
|
||||
src_volume,
|
||||
src_path,
|
||||
fi,
|
||||
dst_volume,
|
||||
dst_path,
|
||||
RenameDataGuards {
|
||||
scanner_publication_lease_token,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
.result
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip_all)]
|
||||
pub(crate) async fn rename_data_observed(
|
||||
&self,
|
||||
src_volume: &str,
|
||||
src_path: &str,
|
||||
fi: &FileInfo,
|
||||
dst_volume: &str,
|
||||
dst_path: &str,
|
||||
guards: RenameDataGuards,
|
||||
) -> RenameDataObservation {
|
||||
let RenameDataGuards {
|
||||
scanner_publication_lease_token,
|
||||
connect_deadline,
|
||||
..
|
||||
} = guards;
|
||||
let multipart_rename = src_volume == crate::disk::RUSTFS_META_MULTIPART_BUCKET;
|
||||
let pool_meta_cas = rustfs_utils::http::metadata_compat::contains_key_str(
|
||||
&fi.metadata,
|
||||
@@ -3453,7 +3502,7 @@ impl RemoteDisk {
|
||||
|| dst_path != "pool.bin"
|
||||
|| scanner_publication_lease_token.is_some())
|
||||
{
|
||||
return Err(DiskError::UnsupportedDisk);
|
||||
return RenameDataObservation::unknown(Err(DiskError::UnsupportedDisk));
|
||||
}
|
||||
trace!(
|
||||
event = EVENT_REMOTE_DISK_RPC,
|
||||
@@ -3469,11 +3518,24 @@ impl RemoteDisk {
|
||||
"Remote disk RPC started"
|
||||
);
|
||||
|
||||
self.execute_with_timeout_for_op(
|
||||
let mut connect_expired = false;
|
||||
let result = Self::execute_with_timeout_for_op(
|
||||
self,
|
||||
"rename_data",
|
||||
|| async {
|
||||
let prepare_started = rustfs_io_metrics::put_stage_timer();
|
||||
let collect_prepare_timing = prepare_started.is_some();
|
||||
let get_client_started = collect_prepare_timing.then(Instant::now);
|
||||
let client = connect_for_rename(connect_deadline, self.get_client_with_msgpack_policy()).await;
|
||||
rustfs_io_metrics::record_put_object_stage_duration_from(
|
||||
rustfs_io_metrics::PUT_STAGE_SET_DISK_RENAME_REMOTE_CLIENT_GET_CLIENT,
|
||||
get_client_started,
|
||||
);
|
||||
let Some(client) = client else {
|
||||
connect_expired = true;
|
||||
return Err(DiskError::DiskNotFound);
|
||||
};
|
||||
let (mut client, mut policy) = client?;
|
||||
let msgpack_encode_started = collect_prepare_timing.then(Instant::now);
|
||||
let file_info_bin = Bytes::from(encode_file_info_msgpack(fi)?);
|
||||
rustfs_io_metrics::record_put_object_stage_duration_from(
|
||||
@@ -3486,13 +3548,6 @@ impl RemoteDisk {
|
||||
file_info_bin.len(),
|
||||
);
|
||||
}
|
||||
let get_client_started = collect_prepare_timing.then(Instant::now);
|
||||
let client = self.get_client_with_msgpack_policy().await;
|
||||
rustfs_io_metrics::record_put_object_stage_duration_from(
|
||||
rustfs_io_metrics::PUT_STAGE_SET_DISK_RENAME_REMOTE_CLIENT_GET_CLIENT,
|
||||
get_client_started,
|
||||
);
|
||||
let (mut client, mut policy) = client?;
|
||||
let bucket_incarnation_id = crate::store::bucket_heal_scope_for_object(dst_volume, dst_path)
|
||||
.map(|scope| Bytes::copy_from_slice(scope.incarnation.as_bytes()))
|
||||
.unwrap_or_default();
|
||||
@@ -3673,7 +3728,11 @@ impl RemoteDisk {
|
||||
},
|
||||
get_max_timeout_duration(),
|
||||
)
|
||||
.await
|
||||
.await;
|
||||
RenameDataObservation {
|
||||
result,
|
||||
rejected_before_publication: connect_expired,
|
||||
}
|
||||
}
|
||||
|
||||
/// Delete a path while binding the target-side operation to a scanner
|
||||
@@ -6484,6 +6543,66 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn rename_connect_budget_only_starts_after_the_quorum_signal() {
|
||||
use futures::FutureExt as _;
|
||||
|
||||
let (tx, rx) = tokio::sync::watch::channel(None);
|
||||
let mut dial = std::pin::pin!(connect_for_rename(Some(rx), std::future::pending::<()>()));
|
||||
assert!(dial.as_mut().now_or_never().is_none());
|
||||
time::advance(Duration::from_secs(2)).await;
|
||||
assert!(dial.as_mut().now_or_never().is_none(), "quorum has not been reached");
|
||||
|
||||
tx.send_replace(Some(time::Instant::now() + Duration::from_secs(1)));
|
||||
assert!(dial.as_mut().now_or_never().is_none(), "quorum grants a connection grace period");
|
||||
time::advance(Duration::from_secs(1)).await;
|
||||
assert_eq!(dial.await, None, "only the unresolved connection expires");
|
||||
assert_eq!(connect_for_rename(Some(tx.subscribe()), std::future::ready(8)).await, Some(8));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn rename_connect_budget_does_not_cancel_a_dispatched_rpc() {
|
||||
use futures::FutureExt as _;
|
||||
|
||||
runtime_sources::ensure_test_rpc_secret();
|
||||
let peer = TestGrpcPeer::spawn(Bytes::new(), Bytes::new())
|
||||
.await
|
||||
.expect("bind rename peer");
|
||||
peer.peer.serve_rename_data();
|
||||
let gate = Arc::new(TestFormatReadGate::default());
|
||||
*peer.peer.rename_data_reply_gate.lock().expect("rename reply gate") = Some(gate.clone());
|
||||
let disk = remote_disk_for_addr(&peer.addr).await;
|
||||
let (tx, rx) = tokio::sync::watch::channel(None);
|
||||
let file_info = sample_rename_data_file_info();
|
||||
let mut rename = std::pin::pin!(disk.rename_data_observed(
|
||||
"tmp",
|
||||
"source",
|
||||
&file_info,
|
||||
"bucket",
|
||||
"object",
|
||||
RenameDataGuards {
|
||||
connect_deadline: Some(rx),
|
||||
..Default::default()
|
||||
},
|
||||
));
|
||||
time::timeout(Duration::from_secs(5), async {
|
||||
tokio::select! {
|
||||
() = gate.entered.notified() => {},
|
||||
_ = rename.as_mut() => panic!("rename completed before the peer received it"),
|
||||
}
|
||||
})
|
||||
.await
|
||||
.expect("peer should receive the authenticated mutation");
|
||||
|
||||
tx.send_replace(Some(time::Instant::now()));
|
||||
assert!(rename.as_mut().now_or_never().is_none(), "the dispatched mutation must continue to drain");
|
||||
gate.release.cancel();
|
||||
let observed = rename.await;
|
||||
assert!(!observed.rejected_before_publication());
|
||||
observed.result.expect("remote rename should return success");
|
||||
peer.stop().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn multipart_rename_old_peer_rejects_without_legacy_fallback() {
|
||||
runtime_sources::ensure_test_rpc_secret();
|
||||
@@ -6540,7 +6659,7 @@ mod tests {
|
||||
|
||||
for (object, calls) in [("object", 1), ("other-object", 2)] {
|
||||
let result = remote
|
||||
.start_rename_data_batch("tmp", "source", "bucket", object, rename_batch_client_items(&file_infos))
|
||||
.start_rename_data_batch("tmp", "source", "bucket", object, rename_batch_client_items(&file_infos), None)
|
||||
.await;
|
||||
assert!(matches!(result, Err(RenameBatchStartError::UnsupportedBeforeStream)));
|
||||
assert_eq!(
|
||||
@@ -6577,7 +6696,7 @@ mod tests {
|
||||
for width in [2_usize, 4] {
|
||||
let file_infos = (0..width).map(|_| sample_rename_data_file_info()).collect::<Vec<_>>();
|
||||
let mut stream = remote
|
||||
.start_rename_data_batch("tmp", "source", "bucket", "object", rename_batch_client_items(&file_infos))
|
||||
.start_rename_data_batch("tmp", "source", "bucket", "object", rename_batch_client_items(&file_infos), None)
|
||||
.await
|
||||
.unwrap_or_else(|_| panic!("{width}-item real batch must start"));
|
||||
assert_eq!(
|
||||
@@ -6633,7 +6752,7 @@ mod tests {
|
||||
let gate = Arc::clone(remote.rename_admission.as_ref().expect("rename admission enabled"));
|
||||
let file_infos = (0..4).map(|_| sample_rename_data_file_info()).collect::<Vec<_>>();
|
||||
let mut stream = remote
|
||||
.start_rename_data_batch("tmp", "source", "bucket", "object", rename_batch_client_items(&file_infos))
|
||||
.start_rename_data_batch("tmp", "source", "bucket", "object", rename_batch_client_items(&file_infos), None)
|
||||
.await
|
||||
.unwrap_or_else(|_| panic!("real partial batch must start"));
|
||||
|
||||
@@ -7550,6 +7669,7 @@ mod tests {
|
||||
rename_batch_result_limit: Arc<StdMutex<Option<usize>>>,
|
||||
serve_rename_data: Arc<AtomicBool>,
|
||||
rename_data_disks: Arc<StdMutex<Vec<String>>>,
|
||||
rename_data_reply_gate: Arc<StdMutex<Option<Arc<TestFormatReadGate>>>>,
|
||||
object_read_all_disks: Arc<StdMutex<Vec<String>>>,
|
||||
format_data: Bytes,
|
||||
read_all_data: Bytes,
|
||||
@@ -7584,6 +7704,7 @@ mod tests {
|
||||
rename_batch_result_limit: Arc::default(),
|
||||
serve_rename_data: Arc::default(),
|
||||
rename_data_disks: Arc::default(),
|
||||
rename_data_reply_gate: Arc::default(),
|
||||
object_read_all_disks: Arc::default(),
|
||||
format_data,
|
||||
read_all_data,
|
||||
@@ -7711,6 +7832,11 @@ mod tests {
|
||||
.lock()
|
||||
.expect("rename data disks lock poisoned")
|
||||
.push(request.disk);
|
||||
let gate = peer.rename_data_reply_gate.lock().expect("rename reply gate lock").take();
|
||||
if let Some(gate) = gate {
|
||||
gate.entered.notify_one();
|
||||
gate.release.cancelled().await;
|
||||
}
|
||||
let payload = serde_json::to_string(&RenameDataResp {
|
||||
sign: Some(vec![1]),
|
||||
..Default::default()
|
||||
|
||||
@@ -645,7 +645,7 @@ impl LocalDiskWrapper {
|
||||
get_max_timeout_duration()
|
||||
};
|
||||
let observed = run_owned_mutation(external_guard, move || async move {
|
||||
let mut preflight_rejection = None;
|
||||
let mut rejected_before_publication = false;
|
||||
let result = operation
|
||||
.track_disk_health_mutation(
|
||||
"rename_data",
|
||||
@@ -661,7 +661,7 @@ impl LocalDiskWrapper {
|
||||
namespace_owner,
|
||||
))
|
||||
.await;
|
||||
preflight_rejection = observed.preflight_rejection;
|
||||
rejected_before_publication = observed.rejected_before_publication();
|
||||
observed.result
|
||||
},
|
||||
timeout_duration,
|
||||
@@ -670,7 +670,7 @@ impl LocalDiskWrapper {
|
||||
// Health tracking must observe the real disk error, not an Ok tuple.
|
||||
Ok(super::RenameDataObservation {
|
||||
result,
|
||||
preflight_rejection,
|
||||
rejected_before_publication,
|
||||
})
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub(in crate::disk) use self::commit::LocalRenamePreflightRejection;
|
||||
#[cfg(test)]
|
||||
#[path = "local/read_path_tests.rs"]
|
||||
mod read_path_tests;
|
||||
|
||||
@@ -540,7 +540,7 @@ async fn prepare_rename_commit_and_destination_metadata(
|
||||
/// Proof produced only when the local rename returns at an existing access
|
||||
/// preflight, before metadata, backups, or object data can be published.
|
||||
#[derive(Debug)]
|
||||
pub(in crate::disk) struct LocalRenamePreflightRejection(());
|
||||
struct LocalRenamePreflightRejection(());
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct RenameDataState {
|
||||
@@ -2939,7 +2939,7 @@ impl LocalDisk {
|
||||
.await;
|
||||
super::super::RenameDataObservation {
|
||||
result,
|
||||
preflight_rejection: state.preflight_rejection,
|
||||
rejected_before_publication: state.preflight_rejection.is_some(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,24 +130,28 @@ pub(crate) struct RenameDataGuards {
|
||||
pub(crate) scanner_publication_lease_token: Option<Uuid>,
|
||||
pub(crate) external_guard: Option<Arc<dyn Send + Sync>>,
|
||||
pub(crate) namespace_owner: Option<Arc<dyn Send + Sync>>,
|
||||
pub(crate) connect_deadline: Option<RenameConnectDeadline>,
|
||||
}
|
||||
|
||||
/// Local preflight evidence stays outside DiskAPI and the RPC response format.
|
||||
/// The fanout publishes this deadline once enough disks have committed.
|
||||
pub(crate) type RenameConnectDeadline = tokio::sync::watch::Receiver<Option<tokio::time::Instant>>;
|
||||
|
||||
/// Pre-dispatch evidence stays outside DiskAPI and the RPC response format.
|
||||
pub(crate) struct RenameDataObservation {
|
||||
pub(crate) result: Result<RenameDataResp>,
|
||||
preflight_rejection: Option<local::LocalRenamePreflightRejection>,
|
||||
pub(crate) rejected_before_publication: bool,
|
||||
}
|
||||
|
||||
impl RenameDataObservation {
|
||||
fn unknown(result: Result<RenameDataResp>) -> Self {
|
||||
pub(crate) fn unknown(result: Result<RenameDataResp>) -> Self {
|
||||
Self {
|
||||
result,
|
||||
preflight_rejection: None,
|
||||
rejected_before_publication: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn rejected_before_publication(&self) -> bool {
|
||||
self.result.is_err() && self.preflight_rejection.is_some()
|
||||
self.result.is_err() && self.rejected_before_publication
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1388,18 +1392,11 @@ impl Disk {
|
||||
.rename_data_observed_with_guards(src_volume, src_path, fi, dst_volume, dst_path, guards)
|
||||
.await
|
||||
}
|
||||
Disk::Remote(remote_disk) => RenameDataObservation::unknown(
|
||||
Disk::Remote(remote_disk) => {
|
||||
remote_disk
|
||||
.rename_data_borrowed_with_fence(
|
||||
src_volume,
|
||||
src_path,
|
||||
fi,
|
||||
dst_volume,
|
||||
dst_path,
|
||||
guards.scanner_publication_lease_token,
|
||||
)
|
||||
.await,
|
||||
),
|
||||
.rename_data_observed(src_volume, src_path, fi, dst_volume, dst_path, guards)
|
||||
.await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ use std::{
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tokio::io::{AsyncRead, ReadBuf};
|
||||
use tokio::sync::{RwLock, mpsc, oneshot};
|
||||
use tokio::sync::{RwLock, mpsc, oneshot, watch};
|
||||
use tokio::task::JoinSet;
|
||||
|
||||
pub(in crate::set_disk) const EVENT_SET_DISK_READ: &str = "set_disk_read";
|
||||
@@ -3279,6 +3279,7 @@ fn rename_tail_cleanup_queue() -> &'static RenameTailCleanupQueue {
|
||||
}
|
||||
|
||||
const EVENT_SET_DISK_RENAME_ROLLBACK: &str = "set_disk_rename_rollback";
|
||||
const PUT_RENAME_POST_QUORUM_CONNECT_GRACE: Duration = Duration::from_secs(1);
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum RenameDispatchState {
|
||||
@@ -3323,6 +3324,7 @@ struct RenameSlotContext {
|
||||
paths: RenameSlotPaths,
|
||||
successful_completion_rank: Option<Arc<AtomicUsize>>,
|
||||
write_quorum: usize,
|
||||
connect_deadline: Option<disk::RenameConnectDeadline>,
|
||||
}
|
||||
|
||||
struct RenameOutcomeProducerArgs {
|
||||
@@ -3334,6 +3336,7 @@ struct RenameOutcomeProducerArgs {
|
||||
publication_scope: Option<crate::object_api::ScannerPublicationCommitScope>,
|
||||
write_quorum: usize,
|
||||
allow_batch: bool,
|
||||
connect_deadline: Option<disk::RenameConnectDeadline>,
|
||||
}
|
||||
|
||||
struct RenameOutcomeProducers {
|
||||
@@ -3827,6 +3830,7 @@ pub(in crate::set_disk) struct RenameDataFenceOptions<'a> {
|
||||
rollback_receipt: Option<RenameRollbackReceipt>,
|
||||
multipart_proof_authority: Option<crate::disk::multipart_source::ProofVerificationContext>,
|
||||
multipart_commit_owner: Option<Arc<MultipartLogicalGuards>>,
|
||||
bound_connect_after_quorum: bool,
|
||||
}
|
||||
|
||||
impl<'a> RenameDataFenceOptions<'a> {
|
||||
@@ -3842,9 +3846,15 @@ impl<'a> RenameDataFenceOptions<'a> {
|
||||
rollback_receipt: None,
|
||||
multipart_proof_authority: None,
|
||||
multipart_commit_owner: None,
|
||||
bound_connect_after_quorum: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::set_disk) fn with_quorum_bounded_connect(mut self, enabled: bool) -> Self {
|
||||
self.bound_connect_after_quorum = enabled;
|
||||
self
|
||||
}
|
||||
|
||||
pub(in crate::set_disk) fn with_multipart_commit_owner(mut self, owner: Arc<MultipartLogicalGuards>) -> Self {
|
||||
self.multipart_commit_owner = Some(owner);
|
||||
self
|
||||
@@ -4426,6 +4436,7 @@ impl SetDisks {
|
||||
disk::RenameDataGuards {
|
||||
scanner_publication_lease_token: context.scanner_token,
|
||||
namespace_owner: context.namespace_owner.clone(),
|
||||
connect_deadline: context.connect_deadline.clone(),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
@@ -4602,6 +4613,7 @@ impl SetDisks {
|
||||
publication_scope,
|
||||
write_quorum,
|
||||
allow_batch,
|
||||
connect_deadline,
|
||||
} = args;
|
||||
debug_assert!(!allow_batch || publication_scope.is_none());
|
||||
let disk_count = disks.len();
|
||||
@@ -4636,6 +4648,7 @@ impl SetDisks {
|
||||
paths: paths.clone(),
|
||||
successful_completion_rank: successful_completion_rank.clone(),
|
||||
write_quorum,
|
||||
connect_deadline: connect_deadline.clone(),
|
||||
};
|
||||
let resource_unit = resource_unit.clone();
|
||||
let producer = crate::disk::with_optional_resource_unit(resource_unit, async move {
|
||||
@@ -4653,6 +4666,7 @@ impl SetDisks {
|
||||
let group_disks = disks.clone();
|
||||
let group_tokens = fence_tokens.clone();
|
||||
let resource_unit = resource_unit.clone();
|
||||
let connect_deadline = connect_deadline.clone();
|
||||
let producer = crate::disk::with_optional_resource_unit(resource_unit, async move {
|
||||
let prepared = join_all(group.slots.into_iter().map(|slot| {
|
||||
let context = RenameSlotContext {
|
||||
@@ -4665,6 +4679,7 @@ impl SetDisks {
|
||||
paths: paths.clone(),
|
||||
successful_completion_rank: successful_completion_rank.clone(),
|
||||
write_quorum,
|
||||
connect_deadline: connect_deadline.clone(),
|
||||
};
|
||||
async move { (slot, Self::prepare_and_admit_rename_slot(context).await) }
|
||||
}))
|
||||
@@ -4736,6 +4751,7 @@ impl SetDisks {
|
||||
&paths.dst_bucket,
|
||||
&paths.dst_object,
|
||||
items,
|
||||
connect_deadline,
|
||||
)
|
||||
.await
|
||||
}
|
||||
@@ -4844,6 +4860,7 @@ impl SetDisks {
|
||||
rollback_receipt,
|
||||
multipart_proof_authority: _,
|
||||
multipart_commit_owner: _,
|
||||
bound_connect_after_quorum: _,
|
||||
} = fence_options;
|
||||
if let Some(file_info) = disks
|
||||
.iter()
|
||||
@@ -4896,6 +4913,7 @@ impl SetDisks {
|
||||
publication_scope: scanner_publication_commit_scope,
|
||||
write_quorum,
|
||||
allow_batch,
|
||||
connect_deadline: None,
|
||||
});
|
||||
|
||||
let mut commit_tx = Some(commit_tx);
|
||||
@@ -5216,6 +5234,7 @@ impl SetDisks {
|
||||
rollback_receipt,
|
||||
multipart_proof_authority,
|
||||
multipart_commit_owner,
|
||||
bound_connect_after_quorum,
|
||||
} = fence_options;
|
||||
if let Some(file_info) = disks
|
||||
.iter()
|
||||
@@ -5285,6 +5304,13 @@ impl SetDisks {
|
||||
dst_object: fanout_dst_object.clone(),
|
||||
};
|
||||
let allow_batch = !protected_multipart && scanner_publication_commit_scope.is_none();
|
||||
let (connect_deadline_tx, connect_deadline) =
|
||||
if bound_connect_after_quorum && fanout_disks.iter().flatten().any(|disk| !disk.is_local()) {
|
||||
let (tx, rx) = watch::channel(None);
|
||||
(Some(tx), Some(rx))
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
let RenameOutcomeProducers {
|
||||
outcomes: mut outcome_rx,
|
||||
mut tasks,
|
||||
@@ -5297,9 +5323,19 @@ impl SetDisks {
|
||||
publication_scope: scanner_publication_commit_scope,
|
||||
write_quorum,
|
||||
allow_batch,
|
||||
connect_deadline,
|
||||
});
|
||||
let mut results = Vec::with_capacity(disk_count);
|
||||
let mut successful = 0;
|
||||
while let Some(outcome) = outcome_rx.recv().await {
|
||||
if let Some(tx) = connect_deadline_tx.as_ref()
|
||||
&& matches!(&outcome.completion, Ok(Ok(_)))
|
||||
{
|
||||
successful += 1;
|
||||
if successful == write_quorum {
|
||||
tx.send_replace(Some(tokio::time::Instant::now() + PUT_RENAME_POST_QUORUM_CONNECT_GRACE));
|
||||
}
|
||||
}
|
||||
results.push(outcome);
|
||||
}
|
||||
while tasks.join_next().await.is_some() {}
|
||||
@@ -12818,6 +12854,66 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial_test::serial(capacity_dirty_scope)]
|
||||
async fn rename_data_bounds_cold_connect_after_durable_quorum() {
|
||||
const DISKS: usize = 4;
|
||||
let bucket = "rename-connect-tail-bucket";
|
||||
let object = "rename-connect-tail-object";
|
||||
let (dirs, mut disks) = call_counter_local_disks(bucket, DISKS).await;
|
||||
prepare_rename_source_dirs(&dirs, &disks, "source").await;
|
||||
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.expect("bind cold peer");
|
||||
// The TCP socket remains open, but there is no TLS server to finish the dial.
|
||||
let endpoint = crate::disk::endpoint::Endpoint {
|
||||
url: url::Url::parse(&format!("https://{}/data/rustfs0", listener.local_addr().expect("cold peer address")))
|
||||
.expect("cold peer URL"),
|
||||
is_local: false,
|
||||
pool_idx: 0,
|
||||
set_idx: 0,
|
||||
disk_idx: 3,
|
||||
};
|
||||
disks[DISKS - 1] = Some(
|
||||
crate::disk::new_disk(
|
||||
&endpoint,
|
||||
&crate::disk::DiskOption {
|
||||
cleanup: false,
|
||||
health_check: false,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.expect("construct remote disk"),
|
||||
);
|
||||
let file_infos = rename_commit_fileinfos(object, DISKS, "bounded-connect-etag");
|
||||
let commit = temp_env::async_with_vars([(rustfs_config::ENV_INTERNODE_CONNECT_TIMEOUT_SECS, Some("15"))], async {
|
||||
tokio::time::timeout(
|
||||
Duration::from_secs(5),
|
||||
SetDisks::rename_data_owned_with_fence(
|
||||
&disks,
|
||||
(RUSTFS_META_TMP_BUCKET, "source"),
|
||||
file_infos,
|
||||
(bucket, object),
|
||||
false,
|
||||
RenameDataFenceOptions::new(3, None).with_quorum_bounded_connect(true),
|
||||
),
|
||||
)
|
||||
.await
|
||||
.expect("durable quorum must finish before the silent peer's dial deadline")
|
||||
.expect("three durable renames must satisfy write quorum")
|
||||
})
|
||||
.await;
|
||||
assert_eq!(commit.convergence, RenameConvergence::PartialCommit);
|
||||
assert!(commit.needs_immediate_heal());
|
||||
assert!(commit.tail_drain.is_none());
|
||||
for dir in dirs.iter().take(3) {
|
||||
let reopened = reopen_local_disk(dir).await;
|
||||
let stored = reopened
|
||||
.read_version("", bucket, object, "", &ReadOptions::default())
|
||||
.await
|
||||
.expect("quorum metadata survives reopening");
|
||||
assert_eq!(stored.metadata.get("etag").map(String::as_str), Some("bounded-connect-etag"));
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial_test::serial(capacity_dirty_scope)]
|
||||
async fn rename_data_without_tail_handoff_waits_after_write_quorum() {
|
||||
|
||||
@@ -68,7 +68,6 @@ async fn collect_bucket_presence(
|
||||
.into())
|
||||
}
|
||||
|
||||
|
||||
impl SetDisks {
|
||||
/// Require proof from every configured disk before retiring a bucket
|
||||
/// generation whose visible volume was removed outside the storage API.
|
||||
|
||||
@@ -5677,6 +5677,14 @@ impl SetDisks {
|
||||
|| commit_decommission_object_lock_guard.is_some()
|
||||
|| commit_publication_guard.is_some();
|
||||
let commit_write_completion = opts.write_completion;
|
||||
let bound_rename_connect = commit_write_completion == crate::object_api::WriteCompletion::TailDrained
|
||||
&& commit_object_lock_guard.is_some()
|
||||
&& !is_meta_bucketname(bucket)
|
||||
&& !opts.data_movement
|
||||
&& !opts.replication_request
|
||||
&& !quota_mutation_fence
|
||||
&& commit_scanner_publication_scope.is_none()
|
||||
&& scanner_publication_lease_tokens.is_none();
|
||||
let commit_allows_early_ack = write_context.allows_early_ack(commit_write_completion)
|
||||
&& !(opts.data_movement && opts.has_decommission_capacity_reservation())
|
||||
&& commit_owns_namespace_guard
|
||||
@@ -6004,6 +6012,7 @@ impl SetDisks {
|
||||
commit_scanner_publication_lease_tokens.as_ref(),
|
||||
)
|
||||
.with_publication_scope(commit_scanner_publication_scope.clone())
|
||||
.with_quorum_bounded_connect(bound_rename_connect)
|
||||
.with_rollback_receipt(commit_rollback_receipt.clone())
|
||||
.with_namespace_commit_guard(
|
||||
(!is_meta_bucketname(&commit_bucket))
|
||||
|
||||
@@ -288,7 +288,7 @@ impl ECStore {
|
||||
RenameDataGuards {
|
||||
scanner_publication_lease_token: scanner_token,
|
||||
external_guard,
|
||||
namespace_owner: None,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
if scanner_token.is_some() {
|
||||
|
||||
Reference in New Issue
Block a user