Skip to content

Conversation

@arekborucki
Copy link
Collaborator

image

Copy link
Member

@coyotte508 coyotte508 left a comment

Choose a reason for hiding this comment

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

TBH not sure - it's something very specific to our atlas deployment (unless proven otherwise)

IMO it's fine to keep current code (a small improvement would be to make 4 separate http requests maybe, and display immediately the dropdown with loading icons for each count)

But current code works well enough IMO not a priority

@arekborucki
Copy link
Collaborator Author

arekborucki commented Dec 3, 2025

it is also working for normal deployments without analytic node

// Falls back to secondaryPreferred if no ANALYTICS node exists
const analyticsReadPreference = new ReadPreference("secondaryPreferred", [{ nodeType: "ANALYTICS" }, {}]);

my private cluster, simple replica set:
image

@coyotte508
Copy link
Member

yes, my concern is that it's an optimization for us for a specific collection, and it's an open source project. Other users would possibly have different results, and this optimization is not relevant for them (eg if their analytics node is delayed or w/e)

Maybe an alternative is adding an env var for read preference to use by default? And use that for all the "read" queries (including where we used secondaryPreferred earlier)

That way for our case we can make mongoku use the analytics node always, by changing the env var, and it doesn't impact other projects

{
maxTimeMS: mongo.getCountTimeout(),
readPreference: ReadPreference.secondaryPreferred,
readPreference: readPref,
Copy link
Member

Choose a reason for hiding this comment

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

It should be applied to all read calls, or maybe we can just set it in the MongoClientWithMappings constructor:

constructor(url: string, _id: string, name: string) {
super(url);
this.url = url;
this._id = _id;
this.name = name;
}

super(url, {readPreference: ...});

(to avoid editing every db call)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

let me fix it

@arekborucki arekborucki merged commit 7bd31a8 into master Dec 3, 2025
1 check passed
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.

3 participants