Skip to content

Commit 47ff3a8

Browse files
achulkov2robot-piglet
authored andcommitted
Use cell leader address as sanitized host
This PR addresses multiple issues: * Host sanitization was dependent on cell peer hostnames having the same length. The fallback was the local host name, which is different for different peers and can lead to snapshot mismatch. * The sanitized host attribute is only **serialized** when running under error sanitizer guard. However, response errors aren't serialized in `Automaton`, so right now all such errors are returned to the user without the host attribute. Conversely, PRK serialization is performed in `Automaton`, so we were storing the potentially differing host names :) The new approach uses the address of the leading peer in the cell as the sanitized host name, and a fixed placeholder if it is not possible to determine it for some reason. This way we don't need additional options for cellar nodes, since the leader is handling all requests and sanitization is not poisoning any errors. Additionally, the host attribute is always serialized into errors, if available, same as datetime. Also deletes `SanitizeLocalHostName` helper and corresponding unittest as obsolete. --- Pull Request resolved: ytsaurus/ytsaurus#908 commit_hash:04cb44b995e467540d5921d2bf90f2d8c2ac2b06
1 parent fed6ce3 commit 47ff3a8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

yt/yt/core/misc/error.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,12 @@ void Serialize(
336336
.Item("attributes").DoMap([&] (auto fluent) {
337337
if (error.HasOriginAttributes()) {
338338
fluent
339-
.Item("host").Value(GetHost(error))
340339
.Item("pid").Value(error.GetPid())
341340
.Item("tid").Value(error.GetTid())
342341
.Item("thread").Value(error.GetThreadName())
343342
.Item("fid").Value(GetFid(error));
344-
} else if (IsErrorSanitizerEnabled() && HasHost(error)) {
343+
}
344+
if (HasHost(error)) {
345345
fluent
346346
.Item("host").Value(GetHost(error));
347347
}
@@ -455,9 +455,6 @@ void ToProto(NYT::NProto::TError* protoError, const TError& error)
455455
};
456456

457457
if (error.HasOriginAttributes()) {
458-
static const TString HostKey("host");
459-
addAttribute(HostKey, GetHost(error));
460-
461458
static const TString PidKey("pid");
462459
addAttribute(PidKey, error.GetPid());
463460

@@ -469,7 +466,9 @@ void ToProto(NYT::NProto::TError* protoError, const TError& error)
469466

470467
static const TString FidKey("fid");
471468
addAttribute(FidKey, GetFid(error));
472-
} else if (IsErrorSanitizerEnabled() && HasHost(error)) {
469+
}
470+
471+
if (HasHost(error)) {
473472
static const TString HostKey("host");
474473
addAttribute(HostKey, GetHost(error));
475474
}

0 commit comments

Comments
 (0)