Hacker News new | past | comments | ask | show | jobs | submit login

I agree the order in the table is irrelevant. However, the ordering observed by another entity doing 3 different read-only transactions is relevant.

The third party does query 1 and sees [1]. This is a result of the initial state.

The third party does query 2 and sees [1, 10]. This is a result of the second transaction committing. The second transaction just inserts '10' so [1,10] makes sense.

The third party does query 3 and sees [1, 1, 10]. This is a result of the first transaction committing but postgresql pretending it committed before the second transaction. The first transaction inserts the sum of what was in the table. If the first transaction committed first then inserting '1' is allowed in the serial order. It doesn't break the second transaction because the second transaction didn't read any rows. In order to let the transaction commit postgresql pretends that it actually committed first

There is no serial order the transactions could have committed in that would let the third party see these results. However, this allowed in postgresql because postgresql doesn't prevent anomalies that can only be observed across multiple transactions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: