aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorserg-belyakov <serg-belyakov@yandex-team.com>2023-01-18 21:30:09 +0300
committerserg-belyakov <serg-belyakov@yandex-team.com>2023-01-18 21:30:09 +0300
commit3fe90528505b2aa0a4b2dfe7938816aef82649a4 (patch)
treec112dc6cb20c5c66cd87a6bbf779514c29d0777f /library
parent165a931108b2403c481db9430596b2ebef8c5391 (diff)
downloadydb-3fe90528505b2aa0a4b2dfe7938816aef82649a4.tar.gz
BS version control, Interconnect,
BS version control, Interconnect,
Diffstat (limited to 'library')
-rw-r--r--library/cpp/actors/interconnect/interconnect_common.h4
-rw-r--r--library/cpp/actors/interconnect/interconnect_handshake.cpp30
-rw-r--r--library/cpp/actors/protos/interconnect.proto4
3 files changed, 35 insertions, 3 deletions
diff --git a/library/cpp/actors/interconnect/interconnect_common.h b/library/cpp/actors/interconnect/interconnect_common.h
index 309c05bfa3..3364ca4cd9 100644
--- a/library/cpp/actors/interconnect/interconnect_common.h
+++ b/library/cpp/actors/interconnect/interconnect_common.h
@@ -101,8 +101,12 @@ namespace NActors {
TSet<TString> AcceptedTags; // we accept all enlisted version tags of peer nodes, but no others; empty = accept all
};
+ // obsolete compatibility control
TMaybe<TVersionInfo> VersionInfo;
+ std::optional<TString> CompatibilityInfo;
+ std::function<bool(const TString&, TString&)> ValidateCompatibilityInfo;
+
using TPtr = TIntrusivePtr<TInterconnectProxyCommon>;
};
diff --git a/library/cpp/actors/interconnect/interconnect_handshake.cpp b/library/cpp/actors/interconnect/interconnect_handshake.cpp
index 76c7010d3a..df0ca29f2b 100644
--- a/library/cpp/actors/interconnect/interconnect_handshake.cpp
+++ b/library/cpp/actors/interconnect/interconnect_handshake.cpp
@@ -263,11 +263,18 @@ namespace NActors {
}
template<typename T>
+ void SetupCompatibilityInfo(T& proto) {
+ if (Common->CompatibilityInfo) {
+ proto.SetCompatibilityInfo(*Common->CompatibilityInfo);
+ }
+ }
+
+ template<typename T>
void SetupVersionTag(T& proto) {
if (Common->VersionInfo) {
proto.SetVersionTag(Common->VersionInfo->Tag);
for (const TString& accepted : Common->VersionInfo->AcceptedTags) {
- proto.AddAcceptedVersionTags(accepted);
+ proto.AddAcceptedVersionTags(accepted);
}
}
}
@@ -282,6 +289,21 @@ namespace NActors {
}
template<typename T, typename TCallback>
+ void ValidateCompatibilityInfo(const T& proto, TCallback&& errorCallback) {
+ // if possible, use new CompatibilityInfo field
+ if (Common->ValidateCompatibilityInfo && proto.HasCompatibilityInfo()) {
+ TString errorReason;
+ if (!Common->ValidateCompatibilityInfo(proto.GetCompatibilityInfo(), errorReason)) {
+ TStringStream s("Local and peer CompatibilityInfo are incompatible");
+ s << ", errorReason# " << errorReason;
+ errorCallback(s.Str());
+ }
+ } else {
+ ValidateVersionTag(proto, std::forward<TCallback>(errorCallback));
+ }
+ }
+
+ template<typename T, typename TCallback>
void ValidateVersionTag(const T& proto, TCallback&& errorCallback) {
// check if we will accept peer's version tag (if peer provides one and if we have accepted list non-empty)
if (Common->VersionInfo) {
@@ -493,6 +515,7 @@ namespace NActors {
request.SetUUID(Common->ClusterUUID);
}
SetupClusterUUID(request);
+ SetupCompatibilityInfo(request);
SetupVersionTag(request);
if (const ui32 size = Common->HandshakeBallastSize) {
@@ -542,7 +565,7 @@ namespace NActors {
const auto& success = reply.GetSuccess();
ValidateClusterUUID(success, generateError);
- ValidateVersionTag(success, generateError);
+ ValidateCompatibilityInfo(success, generateError);
const auto& s = success.GetSenderActorId();
PeerVirtualId.Parse(s.data(), s.size());
@@ -677,7 +700,7 @@ namespace NActors {
generateError(Sprintf("ReceiverHostName# %s mismatch, expected# %s", request.GetReceiverHostName().data(),
Common->TechnicalSelfHostName.data()));
}
- ValidateVersionTag(request, generateError);
+ ValidateCompatibilityInfo(request, generateError);
// check peer node
auto peerNodeInfo = GetPeerNodeInfo();
@@ -729,6 +752,7 @@ namespace NActors {
Y_VERIFY(record.HasSuccess());
auto& success = *record.MutableSuccess();
SetupClusterUUID(success);
+ SetupCompatibilityInfo(success);
SetupVersionTag(success);
success.SetStartEncryption(Params.Encryption);
if (Common->LocalScopeId != TScopeId()) {
diff --git a/library/cpp/actors/protos/interconnect.proto b/library/cpp/actors/protos/interconnect.proto
index 06899e1650..eed00fc551 100644
--- a/library/cpp/actors/protos/interconnect.proto
+++ b/library/cpp/actors/protos/interconnect.proto
@@ -73,6 +73,8 @@ message THandshakeRequest {
optional bool RequestAuthOnly = 19;
optional bool RequestExtendedTraceFmt = 20;
optional bool RequestExternalDataChannel = 21;
+
+ optional bytes CompatibilityInfo = 22;
}
message THandshakeSuccess {
@@ -96,6 +98,8 @@ message THandshakeSuccess {
optional bool AuthOnly = 12;
optional bool UseExtendedTraceFmt = 13;
optional bool UseExternalDataChannel = 14;
+
+ optional bytes CompatibilityInfo = 15;
}
message THandshakeReply {