[GODRIVER-2305] Empty readPreferenceTags Connection Failure Created: 10/Feb/22  Updated: 28/Oct/23  Resolved: 17/Feb/22

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.8.4

Type: Bug Priority: Minor - P4
Reporter: John Burke Assignee: Benji Rewis (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to GODRIVER-2205 Empty read preference tag sets are in... Closed
Documentation Changes: Not Needed

 Description   

Summary

Per docs (https://docs.mongodb.com/manual/core/read-preference-tags), an empty tag can be used as a "fail-safe" mechanism  to connect to any node regardless of tag:

"To avoid an error if no members match any of the tag specifications, you can add an empty document {{{ }}} as the last element of the tag set to read from any eligible member."

However, when using "readPreferenceTag=" as the last tag set in the connection URI the driver fails to send an empty document in the tag array.  I found a commit (https://github.com/mongodb/mongo-go-driver/commit/bfd961abf162856d6dc7c6d97ec627c18e1ceed0) that seems to simply break instead of treating as an empty document.

How to Reproduce

  1. Standup replica set and provide any tag (ex: {dc: dev} )
  2. Try to connect with URI containing mismatched tag, but with empty tag as a "fail-safe" (ex: ?readPreferenceTag=dc:prod&readPreferenceTag=)
  3. Connection will fail


 Comments   
Comment by Githook User [ 17/Feb/22 ]

Author:

{'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}

Message: GODRIVER-2305 Correctly append empty tagset from URI (#853)
Branch: release/1.8
https://github.com/mongodb/mongo-go-driver/commit/c5019a7c61ef0020205500c140de3d19e5ae3607

Comment by Benji Rewis (Inactive) [ 17/Feb/22 ]

This fix should be available in the next patch release of the Go driver, john08burke (1.8.4).

Comment by Githook User [ 17/Feb/22 ]

Author:

{'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}

Message: GODRIVER-2305 Correctly append empty tagset from URI (#853)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/ee152313663401cd53369440bf015b27e375fd5e

Comment by John Burke [ 16/Feb/22 ]

Great, thanks for the quick fix!

Comment by Benji Rewis (Inactive) [ 16/Feb/22 ]

Thanks again for your report, john08burke. Looks like this is a bug introduced by a previous "fix" GODRIVER-1078. We should indeed be treating readPreferenceTags= as a wild-card for server selection when provided in the URI. Here's a fix: https://github.com/mongodb/mongo-go-driver/pull/853

Comment by Benji Rewis (Inactive) [ 16/Feb/22 ]

Thanks for your bug report, john08burke! We're taking a look now.

Generated at Thu Feb 08 08:38:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.