From 77a89c883d179f7fd0ce1c20ecb210e67df59452 Mon Sep 17 00:00:00 2001 From: drbasic Date: Thu, 25 Jan 2024 19:12:23 +0700 Subject: [PATCH] NBS-4859 Any errors in the mirrored disk replica should be retriable (#237) (#241) --- .../mirror_request_actor.cpp | 4 +- .../partition_nonrepl/part_mirror_ut.cpp | 81 ++++++++++++++++++- 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/cloud/blockstore/libs/storage/partition_nonrepl/mirror_request_actor.cpp b/cloud/blockstore/libs/storage/partition_nonrepl/mirror_request_actor.cpp index 1a2819c4e5b..4d3f5518896 100644 --- a/cloud/blockstore/libs/storage/partition_nonrepl/mirror_request_actor.cpp +++ b/cloud/blockstore/libs/storage/partition_nonrepl/mirror_request_actor.cpp @@ -6,7 +6,9 @@ namespace NCloud::NBlockStore::NStorage { void ProcessMirrorActorError(NProto::TError& error) { - if (error.GetCode() == E_IO || error.GetCode() == E_IO_SILENT) { + if (HasError(error) && error.GetCode() != E_REJECTED) { + // We believe that all errors of the mirrored disk can be fixed by + // repeating the request. error = MakeError(E_REJECTED, FormatError(error)); } } diff --git a/cloud/blockstore/libs/storage/partition_nonrepl/part_mirror_ut.cpp b/cloud/blockstore/libs/storage/partition_nonrepl/part_mirror_ut.cpp index 4446cc5121d..8af6e7d876c 100644 --- a/cloud/blockstore/libs/storage/partition_nonrepl/part_mirror_ut.cpp +++ b/cloud/blockstore/libs/storage/partition_nonrepl/part_mirror_ut.cpp @@ -911,7 +911,8 @@ Y_UNIT_TEST_SUITE(TMirrorPartitionTest) // TODO trigger and test migration for petya and petya#1 } - Y_UNIT_TEST(ShouldTransformIOErrorToRetriable) + + void DoShouldTransformAnyErrorToRetriable(NProto::TError error) { TTestBasicRuntime runtime; @@ -929,7 +930,7 @@ Y_UNIT_TEST_SUITE(TMirrorPartitionTest) const auto blockRange = TBlockRange64::WithLength(1024, 3072); client.WriteBlocksLocal(blockRange, TString(DefaultBlockSize, 'A')); - env.DiskAgentState->Error = MakeError(E_IO, "io error"); + env.DiskAgentState->Error = std::move(error); { TVector blocks; @@ -980,6 +981,82 @@ Y_UNIT_TEST_SUITE(TMirrorPartitionTest) } } + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_FAIL) + { + DoShouldTransformAnyErrorToRetriable(MakeError(E_FAIL, "E_FAIL error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_ARGUMENT) + { + DoShouldTransformAnyErrorToRetriable( + MakeError(E_ARGUMENT, "E_ARGUMENT error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_INVALID_STATE) + { + DoShouldTransformAnyErrorToRetriable( + MakeError(E_INVALID_STATE, "E_INVALID_STATE error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_NOT_FOUND) + { + DoShouldTransformAnyErrorToRetriable( + MakeError(E_TIMEOUT, "E_TIMEOUT error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_TIMEOUT) + { + DoShouldTransformAnyErrorToRetriable( + MakeError(E_TIMEOUT, "E_TIMEOUT error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_UNAUTHORIZED) + { + DoShouldTransformAnyErrorToRetriable( + MakeError(E_UNAUTHORIZED, "E_UNAUTHORIZED error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_ABORTED) + { + DoShouldTransformAnyErrorToRetriable( + MakeError(E_ABORTED, "E_ABORTED error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_TRY_AGAIN) + { + DoShouldTransformAnyErrorToRetriable( + MakeError(E_TRY_AGAIN, "E_TRY_AGAIN error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_IO) + { + DoShouldTransformAnyErrorToRetriable(MakeError(E_IO, "E_IO error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_CANCELLED) + { + DoShouldTransformAnyErrorToRetriable( + MakeError(E_CANCELLED, "E_CANCELLED error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_IO_SILENT) + { + DoShouldTransformAnyErrorToRetriable( + MakeError(E_IO_SILENT, "E_IO_SILENT error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_RETRY_TIMEOUT) + { + DoShouldTransformAnyErrorToRetriable( + MakeError(E_RETRY_TIMEOUT, "E_RETRY_TIMEOUT error")); + } + + Y_UNIT_TEST(ShouldTransformAnyErrorToRetriable_E_PRECONDITION_FAILED) + { + DoShouldTransformAnyErrorToRetriable( + MakeError(E_PRECONDITION_FAILED, "E_PRECONDITION_FAILED error")); + } + Y_UNIT_TEST(ShouldReportSimpleCounters) { TTestBasicRuntime runtime;