Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Fred and Mary start with:

    1 A
    2 B
    3 C

    Fred starts a transaction and updates the first two rows so the table that looks like:

    1 X
    2 Y
    3 C

    In the mean time Mary has started and finished a transaction that updates the third row:

    1 A
    2 B
    3 Z

    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?

    • 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?

      • You can't talk about atomic operations and transactions at the same time - its kind of contradictory. Atomic operations mean that the database is either in a state before the operation or in a state after the operation, and never in between. But transaction means that you can group several actions and execute them so that the database reflect the changes only after the execution of all actions - the transaction can't be atomic in the sense that from inside it you can see the intermediate state. In the exam
      • In most applications, this is allowed because it improves concurrency so much. If you really need to prevent it, you can set the isolation level to SERIALIZABLE, and then additional locks will be used so that you can't modify data that another transaction is currently looking at and potentially preparing to modify.
    • Your imagination is quite likely wrong in this instance.

      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

      • It depends on the isolation level you're using. The default level for InnoDB is a bit safer than the default for Oracle. It is REPEATABLE READ, which does keep a consistent snapshot from the beginning of the transaction. To get something closer to Oracle's default, you can use READ COMMITTED, which only guarantees consistency on a statement level. Both databases support SERIALIZABLE, which does extra locking and prevents some tricky cases like phantom rows.
  • a SELECT will see the latest version of the updated rows, but it might also see older versions of any rows.

    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.

    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.

    I think what this is tryin

    • Here's the problem I have:

      The exception to this rule is that the query sees the changes made by earlier statements within the same transaction.

      So the exception occurs withing a transaction.

      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.

      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?

      • 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 (

  • I was reading a document comparing differences between PostgreSQL and MySQL []. It mentioned the different interpretations of transaction isolation and how some of the MySQL modes are inconsistent and weird.

    When comparing the two models, PostgreSQL enforces client separation where the data operated on is always consistent under all circumstances; as the MVCC documentation states, "the reason that PostgreSQL only provides two isolation levels is that this is the only sensible way to map the standard isolation