concurrency
play

Concurrency www.thoughts-on-java.org Databases try to isolate - PowerPoint PPT Presentation

Concurrency www.thoughts-on-java.org Databases try to isolate concurrent transactions Concurrency Mechanism and isolation levels are database specific Hibernate inherits concurrency control from the database Uses database features


  1. Concurrency www.thoughts-on-java.org

  2. • Databases try to isolate concurrent transactions Concurrency • Mechanism and isolation levels are database specific • Hibernate inherits concurrency control from the database • Uses database features to lock specific records www.thoughts-on-java.org

  3. • Lost update Isolution Issues • 2 transactions update record without isolation • Rollback of transaction 2 removes changes of transaction 1 • Dirty read • Transaction 1 reads uncommitted changes of transaction 2 www.thoughts-on-java.org

  4. • Unrepeatable read Isolation Issues • Transaction reads a record twice and gets different states • Special case: Last commit wins • Transaction 2 overwrites changes of transaction 1 • Phantom read • 2nd execution of query returns data which wasn‘t visible before www.thoughts-on-java.org

  5. • Defined by ANSI SQL standard Isolation Levels • Read uncommitted isolation • Allows dirty reads but not lost updates • Read committed isolation • Allows unrepeatable reads but not dirty reads • JPA default isolation level www.thoughts-on-java.org

  6. • Repeatable read isolation Isolation Levels • Allows phantom reads but not unrepeatable or dirty reads • Serializable isolation • Emulates serial execution of transactions www.thoughts-on-java.org

  7. • Optimistic locking • Detects concurrent modifications during commit Locking • Requires no additional database locks • Pessimistic locking • Locks records in the database to prevent concurrent modifications www.thoughts-on-java.org

Recommend


More recommend