diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/repl/isself.cpp | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/repl/isself.cpp')
| -rw-r--r-- | src/mongo/db/repl/isself.cpp | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/src/mongo/db/repl/isself.cpp b/src/mongo/db/repl/isself.cpp index 1e0ec7dfab7..243a1c065f0 100644 --- a/src/mongo/db/repl/isself.cpp +++ b/src/mongo/db/repl/isself.cpp @@ -163,17 +163,10 @@ std::vector<std::string> getAddrsForHost(const std::string& iporhost, } // namespace -bool isSelf(const HostAndPort& hostAndPort, ServiceContext* const ctx, Milliseconds timeout) { - if (isSelfFastPath(hostAndPort)) { - return true; - } - return isSelfSlowPath(hostAndPort, ctx, timeout); -} - -bool isSelfFastPath(const HostAndPort& hostAndPort) { +bool isSelf(const HostAndPort& hostAndPort, ServiceContext* const ctx) { if (MONGO_unlikely(failIsSelfCheck.shouldFail())) { LOGV2(356490, - "failIsSelfCheck failpoint activated, returning false from isSelfFastPath", + "failIsSelfCheck failpoint activated, returning false from isSelf", "hostAndPort"_attr = hostAndPort); return false; } @@ -229,30 +222,18 @@ bool isSelfFastPath(const HostAndPort& hostAndPort) { } } } - return false; -} -bool isSelfSlowPath(const HostAndPort& hostAndPort, - ServiceContext* const ctx, - Milliseconds timeout) { ctx->waitForStartupComplete(); - if (MONGO_unlikely(failIsSelfCheck.shouldFail())) { - LOGV2(6605000, - "failIsSelfCheck failpoint activated, returning false from isSelfSlowPath", - "hostAndPort"_attr = hostAndPort); - return false; - } try { DBClientConnection conn; - double timeoutSeconds = static_cast<double>(durationCount<Milliseconds>(timeout)) / 1000.0; - conn.setSoTimeout(timeoutSeconds); - - // We need to avoid the "hello" call triggered by a normal connect, which would cause a - // deadlock. 'isSelf' is called by the Replication Coordinator when validating a replica set - // configuration document, but the "hello" command requires a lock on the replication - // coordinator to execute. As such we call we call 'connectSocketOnly', which does not call - // "hello". + conn.setSoTimeout(30); // 30 second timeout + + // We need to avoid the isMaster call triggered by a normal connect, which would + // cause a deadlock. 'isSelf' is called by the Replication Coordinator when validating + // a replica set configuration document, but the 'isMaster' command requires a lock on the + // replication coordinator to execute. As such we call we call 'connectSocketOnly', which + // does not call 'isMaster'. auto connectSocketResult = conn.connectSocketOnly(hostAndPort, boost::none); if (!connectSocketResult.isOK()) { LOGV2(4834700, |
