Skip to content
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

Read preference tags deprecation cause and timeline #13980

Closed
2 tasks done
k4y3ff opened this issue Oct 16, 2023 · 2 comments
Closed
2 tasks done

Read preference tags deprecation cause and timeline #13980

k4y3ff opened this issue Oct 16, 2023 · 2 comments
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone

Comments

@k4y3ff
Copy link

k4y3ff commented Oct 16, 2023

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Hello! 👋

I'm responsible for a codebase that uses a primary read preference for some queries and secondaryPreferred for others. We are adding an analytics node to our MongoDB cluster, however, and thus need to specify read preference tags when using secondaryPreferred to ensure that production application queries are not served by the analytics node.

I've looked in the MongoDB Node.js driver, and read preference tags appear to be supported with no caveats (GitHub / API documentation / documentation). However, reading the Mongoose documentation, it appears that read preference tags are marked as DEPRECATED in version 6+.

Since it is not a breaking change, only a deprecation, this does not seem to be mentioned in the "Migrating from 5.x to 6.x" guide. The PR that added DEPRECATED in the documentation (#12140) does not include a detailed description, either. People seem to be recommending using read preference tags in open issues as late as this March, too.

Could anyone provide more information on why read preference tags are considered deprecated and what the timeline is for sunsetting them?

Thanks in advance.

@IslandRhythms IslandRhythms added the help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary label Oct 16, 2023
@vkarpov15
Copy link
Collaborator

It looks like this "DEPRECATED" line was unintentionally added, I missed this during code review. @hasezoey what was the reason behind marking Aggregate.prototype.read tags param as deprecated here: 437b03a ?

Even without tags param, you can always use .read(new mongoose.mongo.ReadPreference(pref, tags)).

@hasezoey
Copy link
Collaborator

hasezoey commented Oct 19, 2023

i dont know exactly why i added this anymore, but it may have something to do with typescript leading me to mquery when doing a Go to Definition on the Query.prototype.read, which has the following code:

https://github.com/mongoosejs/mquery/blob/e7a8a3099ef282a2d9af36a2880981871adfe9fd/lib/mquery.js#L1603-L1610
(snippit because github only does snippits for same repository):

Query.prototype.read = Query.prototype.setReadPreference = function(pref) {
  if (arguments.length > 1 && !Query.prototype.read.deprecationWarningIssued) {
    console.error('Deprecation warning: \'tags\' argument is not supported anymore in Query.read() method. Please use mongodb.ReadPreference object instead.');
    Query.prototype.read.deprecationWarningIssued = true;
  }
  this.options.readPreference = utils.readPref(pref);
  return this;
};

TL;DR: i likely just didnt properly check that i landed in the mongoose definition instead of the mquery definition of Query.prototype.read

@vkarpov15 vkarpov15 added this to the 7.6.5 milestone Oct 24, 2023
@vkarpov15 vkarpov15 added docs This issue is due to a mistake or omission in the mongoosejs.com documentation and removed help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary labels Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

No branches or pull requests

4 participants