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

concurrency
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Concurrency

www.thoughts-on-java.org

slide-2
SLIDE 2

Concurrency

  • Databases try to isolate concurrent transactions
  • 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

slide-3
SLIDE 3

Isolution Issues

  • Lost update
  • 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

slide-4
SLIDE 4

Isolation Issues

  • Unrepeatable read
  • 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

slide-5
SLIDE 5

Isolation Levels

  • Defined by ANSI SQL standard
  • 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

slide-6
SLIDE 6

Isolation Levels

  • Repeatable read isolation
  • Allows phantom reads but not unrepeatable or dirty reads
  • Serializable isolation
  • Emulates serial execution of transactions

www.thoughts-on-java.org

slide-7
SLIDE 7

Locking

  • Optimistic locking
  • Detects concurrent modifications during commit
  • Requires no additional database locks
  • Pessimistic locking
  • Locks records in the database to prevent concurrent

modifications

www.thoughts-on-java.org