PostgreSQL禁止的异象是什么
发表于:2025-11-07 作者:千家信息网编辑
千家信息网最后更新 2025年11月07日,这篇文章主要讲解了"PostgreSQL禁止的异象是什么",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"PostgreSQL禁止的异象是什么"吧!测试数
千家信息网最后更新 2025年11月07日PostgreSQL禁止的异象是什么
这篇文章主要讲解了"PostgreSQL禁止的异象是什么",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"PostgreSQL禁止的异象是什么"吧!
测试数据
数据表idx,在id列上有索引,数据库默认的隔离级别为可串行化
15:44:16 [local:/data/run/pg12]:5120 pg12@testdb=# \d+ idx Table "public.idx" Column | Type | Collation | Nullable | Default | Storage | Statstarget | Description--------+-------------------+-----------+----------+---------+----------+--------------+------------- id | integer | | | | plain | | c1 | character varying | | | | extended | |Indexes: "idx_id" btree (id)Access method: heap[pg12@localhost pg122db]$ grep 'isolation' postgresql.confdefault_transaction_isolation = 'SERIALIZABLE'
Write触发
操作序列如下:
| 时间点 | T1 | T2 | T3 |
|---|---|---|---|
| t1 | begin; | ||
| t2 | select * from idx where id = 1; | ||
| t3 | begin; | ||
| t4 | select * from idx where id = 10000; | ||
| t5 | begin; | ||
| t6 | update idx set c1 = 'x' where id = 10000; | ||
| t7 | commit; | ||
| t8 | update idx set c1 = 'x' where id = 1; |
session 2(T2)在执行update操作时会报错
-- session 215:46:52 [local:/data/run/pg12]:5120 pg12@testdb=#* update idx set c1 = 'x' where id = 1;ERROR: could not serialize access due to read/write dependencies among transactionsDETAIL: Reason code: Canceled on identification as a pivot, during write.HINT: The transaction might succeed if retried.15:47:10 [local:/data/run/pg12]:5120 pg12@testdb=#!
Read触发
操作序列如下:
| 时间点 | T1 | T2 | T3 |
|---|---|---|---|
| t1 | begin; | ||
| t2 | select * from idx where id = 1; | ||
| t3 | begin; | ||
| t4 | update idx set c1 = 'x1' where id = 1; | ||
| t5 | begin; | ||
| t6 | update idx set c1 = 'x' where id = 10000; | ||
| t7 | commit; | ||
| t8 | select * from idx where id = 10000; |
session 2(T2)在执行select操作时会报错
15:54:41 [local:/data/run/pg12]:5120 pg12@testdb=#* select * from idx where id = 10000;ERROR: could not serialize access due to read/write dependencies among transactionsDETAIL: Reason code: Canceled on conflict out to pivot 423284, during read.HINT: The transaction might succeed if retried.15:55:16 [local:/data/run/pg12]:5120 pg12@testdb=#!
commit触发
操作序列如下:
| 时间点 | T1 | T2 |
|---|---|---|
| t1 | begin; | |
| t2 | select * from idx where id = 1; | |
| t3 | update tbl set c1 = 'x' where id = 10000; | |
| t4 | begin; | |
| t5 | select * from idx where id = 10000; | |
| t6 | update idx set c1 = 'x' where id = 1; | |
| t7 | commit; | |
| t8 | commit; |
T1执行commit的时候会报错:
16:07:50 [local:/data/run/pg12]:5120 pg12@testdb=#* commit;ERROR: could not serialize access due to read/write dependencies among transactionsDETAIL: Reason code: Canceled on identification as a pivot, during commit attempt.HINT: The transaction might succeed if retried.
感谢各位的阅读,以上就是"PostgreSQL禁止的异象是什么"的内容了,经过本文的学习后,相信大家对PostgreSQL禁止的异象是什么这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
序列
数据
时间
会报
学习
内容
就是
思路
情况
数据库
数据表
文章
时候
更多
知识
知识点
篇文章
索引
级别
跟着
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网科技商业计划书模板
对自己的网络安全保护
mincraft 数据库
网络安全与网络文明心得
存薪水 类型 数据库
mc服务器防爆是关tnt还是
素描网络安全系列
郑州网络安全宣传论坛
查询数据库所有主键
中科院专家谈网络安全
079冒险岛怪物数据库
帆软nginx服务器
连接第三方服务器失败是啥意思
iv级网络安全事件
路由DNS服务器异常
2021浪潮校招软件开发题
常用的数据库语言
湖南美租网络技术有限公司
网络安全扫描图片素材
广东工业软件开发多少钱
手游玩端游cf连接端游服务器
板材套料软件开发商
13个根服务器都是什么
数据库对接分析工具
网神服务器管理ip地址是什么
电脑上网软件无法连接服务器
数据库的安全管理机制是
数据库信息系统的核心技术
短机架服务器
数据库表空间未释放