-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
upsert is using read replica for select #4868
Comments
I tried to debug it, and it works as expected when I add. |
Yes, that place looks good, also the same will need to happen for mikro-orm/packages/core/src/EntityManager.ts Lines 915 to 919 in 22e140e
|
Ok, I will prepare PR with the fix, but right now, I am unsure how to write a test for this (I never saw Mikro-orm tests), so I will probably need help with that. |
You could just add them in here, and assert the connection type the same way as the other tests (via logs): https://github.com/mikro-orm/mikro-orm/blob/master/tests/features/read-replicas.test.ts |
I opened PR with fix |
Describe the bug
When using
em.upsert()
with read replicas andpreferReadReplicas: true
. The select query that follows the insert query uses the read connections. Probably due to replication lag the hydration fails. I tried settingpreferReadReplicas: false
and it works as expected.Stack trace
Expected behavior
em.upsert
will always use a write connection regardless ofpreferReadReplicas
flag.Versions
The text was updated successfully, but these errors were encountered: