Skip to content

Conversation

@matejk
Copy link
Contributor

@matejk matejk commented Nov 27, 2025

No description provided.

@matejk matejk self-assigned this Nov 27, 2025
@matejk matejk added the feature label Nov 27, 2025
@matejk matejk changed the title Mongodb replica set support MongoDB replica set support Nov 27, 2025
{
_type = Single;
}
else if (primaries > 0)

Check warning

Code scanning / CodeQL

Comparison result is always the same Warning

Comparison is always false because primaries <= 0.

Copilot Autofix

AI about 6 hours ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

{
_type = ReplicaSetWithPrimary;
}
else if (secondaries > 0 || !_setName.empty())

Check warning

Code scanning / CodeQL

Comparison result is always the same Warning

Comparison is always false because secondaries <= 0.

Copilot Autofix

AI about 6 hours ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

}

// Determine topology type
if (mongosCount > 0)

Check warning

Code scanning / CodeQL

Comparison result is always the same Warning

Comparison is always false because mongosCount <= 0.
{
_type = Sharded;
}
else if (standaloneCount > 0 && _servers.size() == 1)

Check warning

Code scanning / CodeQL

Comparison result is always the same Warning

Comparison is always false because standaloneCount <= 0.

Copilot Autofix

AI about 9 hours ago

To fix the issue (comparison is always false because standaloneCount <= 0), you should remove or revise the check that tests whether standaloneCount > 0 && _servers.size() == 1 on line 303. If the design means standalone servers are not present in _servers at this point, then the branch is dead code and should be deleted. The best fix is to safely remove the conditional branch and any associated comments describing what happens if there's a standalone server, only if this doesn't affect overall functionality or logic elsewhere. Make this change only to the block on lines 303–308, being careful to preserve other functionality and comments.

No imports or new methods are needed.

Suggested changeset 1
MongoDB/src/TopologyDescription.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/MongoDB/src/TopologyDescription.cpp b/MongoDB/src/TopologyDescription.cpp
--- a/MongoDB/src/TopologyDescription.cpp
+++ b/MongoDB/src/TopologyDescription.cpp
@@ -300,12 +300,12 @@
 	{
 		_type = Sharded;
 	}
-	else if (standaloneCount > 0 && _servers.size() == 1)
-	{
-		// Single standalone server - treat as Single topology
-		// Standalone servers behave like a single primary for read preferences
-		_type = Single;
-	}
+	// else if (standaloneCount > 0 && _servers.size() == 1)
+	// {
+	// 	// Single standalone server - treat as Single topology
+	// 	// Standalone servers behave like a single primary for read preferences
+	// 	_type = Single;
+	// }
 	else if (primaries > 0)
 	{
 		_type = ReplicaSetWithPrimary;
EOF
@@ -300,12 +300,12 @@
{
_type = Sharded;
}
else if (standaloneCount > 0 && _servers.size() == 1)
{
// Single standalone server - treat as Single topology
// Standalone servers behave like a single primary for read preferences
_type = Single;
}
// else if (standaloneCount > 0 && _servers.size() == 1)
// {
// // Single standalone server - treat as Single topology
// // Standalone servers behave like a single primary for read preferences
// _type = Single;
// }
else if (primaries > 0)
{
_type = ReplicaSetWithPrimary;
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants