-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix(drizzle): upsert row error when using read replicas #13023
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
base: main
Are you sure you want to change the base?
Conversation
if (!doc) { | ||
return { ...data, ...insertedRow } as T | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it's the best way to handle this.
The returned data can miss a lot of information or have it in a different shape (because the transform
function doesn't run here).
Would skip of using read replicas for that db.query
call help here? I guess so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @r1tsuu, yes I thought about skipping read replica here and just reading from the primary. But I had 2 issues:
- I wasn't exactly sure how to do it here as the
db.query[xxxx]
object wasn't type hinted, and I guess didn't also want to spend too much time figuring it out due to the second issue below. - I wondered if that would also defeat the purpose of using a read replica – considering a use-case of high volume ingestion.
So this was just an attempt at a workaround, and hopefully get you guys to pick up this issue - as it is really making the whole read-replica feature unusable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the transform function doesn't run here
Can I also run the transform and use the { ...data, ...insertedRow }
as a fallback for the nullable doc
instead of just returning it?
…load into fix/upsert-with-read-replica
As highlighted in this issue, retrieving a newly created row when using read replicas will sometimes fail as there is usually some lag time between replication.