DB configuration for primary and read-replica instance in adapters #7602
vibhor-web-headout
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We have a MongoDB / AWS DocumentDB cluster that we want to configure on Payload.
The read preference we want is
secondaryPreference
but we also want to enableautoCreate
&autoIndex
options.Due to Mongoose's restriction on having both the above in a single connection call, more details here, it is difficult to achieve this in payload since we only have a single adapter instance to provide.
I believe they want us to configure two connections in the application, one for primary with the
autoCreate
&autoIndex
set and another (secondary / read-replica) for all reads.I am not sure how to achieve this in Payload.
Since Mongoose schema is also something that is abstracted within Payload, don't think I should be taking out the core logic and triggering the connection manually.
I have considered initializing payload twice (sequentially) with different DB configurations i.e. primary first to auto index & create and then secondary.
Or create a separate script that runs outside the starting payload server which would make a connection to the primary and sync schema and die, letting the required application server start later.
Wanted to understand if there is a better way to achieve this.
Beta Was this translation helpful? Give feedback.
All reactions