h2database源码浅析:事务、两阶段提交
来源:互联网 发布:山西大学网络管理系统 编辑:程序博客网 时间:2024/06/08 14:19
Transaction Isolation
Transaction isolation is provided for all data manipulation language (DML) statements. Most data definition language (DDL) statements commit the current transaction. See the Grammar for details.
This database supports the following transaction isolation levels:
- Read Committed
This is the default level. Read locks are released immediately after executing the statement, but write locks are kept until the transaction commits. Higher concurrency is possible when using this level.
To enable, execute the SQL statementSET LOCK_MODE 3
or append;LOCK_MODE=3
to the database URL:jdbc:h2:~/test;LOCK_MODE=3
- Serializable
Both read locks and write locks are kept until the transaction commits. To enable, execute the SQL statementSET LOCK_MODE 1
or append;LOCK_MODE=1
to the database URL:jdbc:h2:~/test;LOCK_MODE=1
- Read Uncommitted
This level means that transaction isolation is disabled.
To enable, execute the SQL statementSET LOCK_MODE 0
or append;LOCK_MODE=0
to the database URL:jdbc:h2:~/test;LOCK_MODE=0
When using the isolation level 'serializable', dirty reads, non-repeatable reads, and phantom reads are prohibited.
- Dirty Reads
Means a connection can read uncommitted changes made by another connection.
Possible with: read uncommitted - Non-Repeatable Reads
A connection reads a row, another connection changes a row and commits, and the first connection re-reads the same row and gets the new result.
Possible with: read uncommitted, read committed - Phantom Reads
A connection reads a set of rows using a condition, another connection inserts a row that falls in this condition and commits, then the first connection re-reads using the same condition and gets the new row.
Possible with: read uncommitted, read committed
Two Phase Commit
The two phase commit protocol is supported. 2-phase-commit works as follows:
- Autocommit needs to be switched off
- A transaction is started, for example by inserting a row
- The transaction is marked 'prepared' by executing the SQL statement
PREPARE COMMIT transactionName
- The transaction can now be committed or rolled back
- If a problem occurs before the transaction was successfully committed or rolled back (for example because a network problem occurred), the transaction is in the state 'in-doubt'
- When re-connecting to the database, the in-doubt transactions can be listed with
SELECT * FROM INFORMATION_SCHEMA.IN_DOUBT
- Each transaction in this list must now be committed or rolled back by executing
COMMIT TRANSACTION transactionName
orROLLBACK TRANSACTION transactionName
- The database needs to be closed and re-opened to apply the changes
0 0
- h2database源码浅析:事务、两阶段提交
- 两阶段提交事务
- 两阶段提交事务
- h2database源码浅析:集群
- 事务和两阶段提交
- 事务和两阶段提交
- 事务和两阶段提交
- 事务和两阶段提交
- 事务与两阶段提交
- 分布式事务---两阶段提交
- 两阶段提交-分布式事务
- 分布式事务-两阶段提交
- 事务与两阶段提交
- 分布式事务、XA事务、两阶段提交
- 分布式事务、XA事务、两阶段提交
- 分布式事务、XA事务、两阶段提交
- 分布式事务 - 两阶段提交与三阶段提交
- 分布式事务 - 两阶段提交与三阶段提交
- 视频:《噬神者2:狂怒解放》公开游戏开场动画欣赏
- Kafka使用及开发概要
- 树莓派8188eu驱动
- Android Context 上下文 你必须知道的一切
- 5个数求最值
- h2database源码浅析:事务、两阶段提交
- Linq入门
- 奋斗的小蜗牛
- 递归逆序打印单链表(c实现)
- h2database源码浅析:锁与MVCC
- 小光棍数
- MVC 控制器向View传值的三种方法
- 华为机试—字符串去重排序
- 奇偶数分离