0

We have an issue where we write to the master table, then immediately must read using the reader. We are experiencing issues with replication lag where the data is not available to the reader at the time we execute our read statement (our replication lag is around 18 ms, which seems pretty fast so I don't think it's a problem with having too much lag).

What patterns are there to deal with this problem? So far our solutions are:

  1. Just use the writer to read

  2. Put logic in our code to wait for replication to occur

Are there any other ways of dealing with this?

  • You'd have to use synchronous replication with synchronous_commit = remote_apply, but I don't know if Amazon supports that. Replication is not very useful for load balancing. – Laurenz Albe Oct 29 at 23:08
0

We have an issue where we write to the master table, then immediately must read ...

If the Requirement is that the read is time-critical and must have the very latest data, then read the very latest data - from the master.
This is especially true if you're generating values as part of the update and need to retrieve them, which you should ideally do within the same transaction. (Actually, that's about the only reason I can think of that you'd need to read back the [same] data that you've just saved).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.