Skip to content

Commit

Permalink
Do not retry CLIENT_UNAUTHENTICATED & CLIENT_CALL_UNIMPLEMENTED (#10465)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberROFL authored Oct 15, 2024
1 parent 3ab7dd7 commit 1aab418
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
28 changes: 28 additions & 0 deletions ydb/core/tx/replication/controller/target_discoverer_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <ydb/core/tx/replication/ut_helpers/test_env.h>
#include <ydb/core/tx/replication/ut_helpers/test_table.h>
#include <ydb/core/tx/replication/ydb_proxy/ydb_proxy.h>

#include <library/cpp/testing/unittest/registar.h>

Expand Down Expand Up @@ -130,6 +131,33 @@ Y_UNIT_TEST_SUITE(TargetDiscoverer) {
UNIT_ASSERT_VALUES_EQUAL(toAdd.size(), 1);
UNIT_ASSERT_VALUES_EQUAL(toAdd.at(0).SrcPath, "/Root/Table");
}

Y_UNIT_TEST(InvalidCredentials) {
TEnv env;
env.GetRuntime().SetLogPriority(NKikimrServices::REPLICATION_CONTROLLER, NLog::PRI_TRACE);

env.CreateTable("/Root", *MakeTableDescription(DummyTable()));

// create aux proxy
NKikimrReplication::TStaticCredentials staticCreds;
staticCreds.SetUser("user");
staticCreds.SetPassword("password");
const auto ydbProxy = env.GetRuntime().Register(CreateYdbProxy(
env.GetEndpoint(), env.GetDatabase(), false /* ssl */, staticCreds));

env.GetRuntime().Register(CreateTargetDiscoverer(env.GetSender(), 1, ydbProxy,
TVector<std::pair<TString, TString>>{
{"/Root", "/Root/Replicated"},
}
));

auto ev = env.GetRuntime().GrabEdgeEvent<TEvPrivate::TEvDiscoveryTargetsResult>(env.GetSender());
UNIT_ASSERT(!ev->Get()->IsSuccess());

const auto& failed = ev->Get()->Failed;
UNIT_ASSERT_VALUES_EQUAL(failed.size(), 1);
UNIT_ASSERT_VALUES_EQUAL(failed.at(0).Error.GetStatus(), NYdb::EStatus::CLIENT_UNAUTHENTICATED);
}
}

}
8 changes: 7 additions & 1 deletion ydb/core/tx/replication/controller/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ inline auto DefaultRetryableErrors() {
}

inline bool IsRetryableError(const NYdb::TStatus status, const TVector<NYdb::EStatus>& retryable) {
return status.IsTransportError() || Find(retryable, status.GetStatus()) != retryable.end();
switch (status.GetStatus()) {
case NYdb::EStatus::CLIENT_UNAUTHENTICATED:
case NYdb::EStatus::CLIENT_CALL_UNIMPLEMENTED:
return false;
default:
return status.IsTransportError() || Find(retryable, status.GetStatus()) != retryable.end();
}
}

inline bool IsRetryableError(const NYdb::TStatus status) {
Expand Down

0 comments on commit 1aab418

Please sign in to comment.