Skip to content

PYTHON-2791 Ignore erroneous serviceId field for non-LB connections #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2021

Conversation

ShaneHarvey
Copy link
Member

The serviceId field is not supposed to be returned for non-LB mode. This change fixes the pymongo bug in the ticket by removing the field (if it exists) when in non-LB mode.

@prashantmital
Copy link
Contributor

If this is a serverless bug should add a comment that the special-casing needs to be removed once serverless fixes the problem upstream?

@prashantmital
Copy link
Contributor

On a second thought, lets leave this open for the time being. The code change is small enough that I can manually copy it to get unblocked on serverless testing.

@ShaneHarvey
Copy link
Member Author

I'd like to merge this instead of wait for serverless testing. I've added a test. We can remove the pool logic in PYTHON-2712 when we remove the other serviceId related code.

@@ -361,7 +361,7 @@ def updated_topology_description(topology_description, server_description):
topology_description._topology_settings)

if topology_type == TOPOLOGY_TYPE.Unknown:
if server_type == SERVER_TYPE.Standalone:
if server_type in (SERVER_TYPE.Standalone, SERVER_TYPE.LoadBalancer):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So with multiple seeds + LB we will now end up removing hosts until we have only one left and then connect to that as a Single?
Is this what the spec says to do or is this behavior undefined?

Copy link
Member Author

@ShaneHarvey ShaneHarvey Jul 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment in the test case. This is unreachable code in practice. It's just a failsafe in case the "serviceId" popping logic doesn't work or gets removed prematurely.

self.assertEqual(t.description.topology_type_name, 'Single')
self.assertTrue(t.description.has_writable_server())

# Load balancers are removed from a topology with multiple seeds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if both a and b advertise a serviceId?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They'd both get removed. No need to test it though since this is unreachable in practice. We don't need to test every combination IMO.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reading of the code tells me that if the serviceId popping fails, we'll be left with one LB to which we'll connect as a standalone but I take your point that this is unreachable - we can leave it at that.

Copy link
Contributor

@prashantmital prashantmital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming tests pass.

@prashantmital
Copy link
Contributor

To clarify, is the plan to revert this change entirely as part of PYTHON-2712? If so, can you make a note about the same on the ticket?

@ShaneHarvey ShaneHarvey merged commit b823b95 into mongodb:master Jul 1, 2021
ShaneHarvey added a commit that referenced this pull request Jul 1, 2021
@ShaneHarvey ShaneHarvey deleted the PYTHON-2791 branch July 1, 2021 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants