-
Enhancement
-
Resolution: Done
-
Major
-
None
-
None
-
False
-
None
-
False
Feature request or enhancement
For feature requests or enhancements, provide this information, please:
Which use case/requirement will be addressed by the proposed feature?
we are running change streams in full document mode which fetches the current version of the target document for all update operations, requiring an additional find for all update events. Running this process even on a secondary node has had a significant impact on our database's performance and health. Therefore, we were advised by MongoDB to run this workload on a separate isolated Analytics node. To connect to the Analytics node in the MongoDB, we need to add read preference tags to the connection string as shown below
readPreference=secondary&readPreferenceTags=nodeType%3AANALYTICS
However, it seems that the read preference is hard-coded to "secondaryPreferred" in the Debezium code where the [client] (https://github.com/debezium/debezium/blob/b3efdc00144afa70b8a7ce6e999d4dc0b7111e01/debezium-connector-mongodb/src/main/java/io/debezium/connector/mongodb/connection/MongoDbClientFactory.java#L58) is created. It appears that in the [MongoDB Java driver] (https://github.com/mongodb/mongo-java-driver/blob/fd2f8cc988d4acdaaa1f65ae6def82ab9af2bfb0/driver-core/src/main/com/mongodb/ConnectionString.java#L940), both the read preference and read preference tags need to be set together. Since only the read preference is being set in the Debezium code, the read preference tags from the connection string are discarded.
The read preference tags can be set in the connection string like below:
readPreference=secondary&readPreferenceTags=nodeType%3AANALYTICS
Implementation ideas (optional)
- Our team has already modified the Debezium code to eliminate the hard-coded read preference and enable setting it via the connection string. We have successfully tested this approach.
Below is the part of the queries from debezium from the MongoDB profiler before and after this change.
"$readPreference": { "mode": "secondary", "tags": [ { "nodeType": "ANALYTICS" } ] }
"$readPreference": { "mode": "secondaryPreferred" }
2. When creating the client, set the read preference tags if any are included in the connection string.
- is incorporated by
-
DBZ-6578 Debezium should honor read preference from connection string
- Closed
- relates to
-
DBZ-6521 MongoDB change stream pipeline not respecting hard coded `readPreference=secondaryPreferred`
- Closed
- links to
-
RHEA-2024:129636 Red Hat build of Debezium 2.5.4 release