Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.
When using InnoDB and MySQL, you can avoid row-level locking when selecting data, thus avoiding a potential performance problem. This is done via a "consistent read". From the latest MySQL docs on consistent reads:
A consistent read means that InnoDB uses multi-versioning to present to a query a snapshot of the database at a point in time. The query sees the changes made by those transactions that committed before that point of time, and no changes made by later or uncommitted transactions.
So far, so good. You get a snapshot of data to read and nothing will be updating it underneath you.
The exception to this rule is that the query sees the changes made by earlier statements within the same transaction.
That makes sense. If I change data in a transaction, a subsequent select in the same transaction had better see my changes.
Here's where I get nervous (emphasis mine):
Note that the exception to the rule causes the following anomaly: if you update some rows in a table, a SELECT will see the latest version of the updated rows, but it might also see older versions of any rows. If other users simultaneously update the same table, the anomaly means that you may see the table in a state that never existed in the database.
What? I've read that several times and I still don't get it. What does "older versions of any rows" mean? And what does "may see
This can't be right. Can someone please explain what I'm missing?
I would imagine something like this: (Score:1)
Fred and Mary start with:
Fred starts a transaction and updates the first two rows so the table that looks like:
In the mean time Mary has started and finished a transaction that updates the third row:
which means that Fred is seeing the "old" version of row three, and the table as a whole reflects something that will never have existed in the database.
Make sense?
Re: (Score:2)
Oh! I replied to Aristotle without thinking too carefully about your reply. I can see how this could occur, but it's problematic because then things aren't atomic. If you take actions based upon this, you can still corrupt your data. You update row 3 because 'C' is there, but it's really not. Now you have a race condition because consistent reads aren't. Or did I misunderstand something?
Re: (Score:1)
Re: (Score:1)
Re: (Score:1)
I don't have a MySQL database to play with, but if that was Oracle then by default in your situation, Fred will see a Z in the third row. The reason is that consistent reads are consistent at the statement level, not the transaction level. So you see changes that have been committed after your transaction started, but before your statement began.
The technical reason for this is that with Oracle's implementation, consistent reads have to be done b
Re: (Score:1)
I think… (Score:1)
I think the key is the “any”, and what they are trying to say is that if you start a transaction, you will only see rows as they were at the time of the transaction start, plus newer data in rows you updated since.
I think what this is tryin
Re: (Score:2)
Here's the problem I have:
So the exception occurs withing a transaction.
So the exception occurs within a transaction. The anomaly occurs when several uses update the same table. How does that happen within a single transaction?
Re: (Score:1)
It doesn’t happen in a single transaction.
You see the updates you made, plus the rows you didn’t touch in whatever state they were when you started. This is within the transaction.
By the time you commit your changes, the rows you didn’t change may differ from what they were when you started the transaction. Obviously, if they differ, this must be because other users updated the table alongside your transaction.
So the particular world that you were seeing from within the transaction (
Relevant quote (Score:1)