So far, you have learned a lot about replication. In the next step, it is important to take a look at replication conflicts. The main question that arises is this: how can a conflict ever happen in the first place?
Consider the following example:
Master |
Slave |
BEGIN; |
|
SELECT ... FROM tab WHERE ... |
|
... running ... |
|
DROP TABLE tab; |
... conflict happens ... |
... transaction is allowed to continue for 30 seconds ... |
|
... conflict is resolved or ends before timeout ... |
The problem here is that the master does not know that there is a transaction happening on the slave. Therefore, the DROP TABLE command does not block until the reading transaction is gone. If those two transactions happened ...