久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

PostgreSQL禁止的異象是什么

135次閱讀
沒有評論

共計 2317 個字符,預(yù)計需要花費 6 分鐘才能閱讀完成。

這篇文章主要講解了“PostgreSQL 禁止的異象是什么”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著丸趣 TV 小編的思路慢慢深入,一起來研究和學(xué)習(xí)“PostgreSQL 禁止的異象是什么”吧!

測試數(shù)據(jù)

數(shù)據(jù)表 idx,在 id 列上有索引,數(shù)據(jù)庫默認(rèn)的隔離級別為可串行化

15:44:16 [local:/data/run/pg12]:5120 pg12@testdb=# \d+ idx
 Table  public.idx 
 Column | Type | Collation | Nullable | Default | Storage | Stats
target | Description
--------+-------------------+-----------+----------+---------+----------+-------
-------+-------------
 id | integer | | | | plain |
 |
 c1 | character varying | | | | extended |
 |
Indexes:
  idx_id  btree (id)
Access method: heap
[pg12@localhost pg122db]$ grep  isolation  postgresql.conf
default_transaction_isolation =  SERIALIZABLE

Write 觸發(fā)

操作序列如下:

時間點 T1T2T3t1begin;

t2select * 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)在執(zhí)行 update 操作時會報錯

-- session 2
15: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 transactions
DETAIL: 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 觸發(fā)

操作序列如下:

時間點 T1T2T3t1begin;

t2select * 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)在執(zhí)行 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 transactions
DETAIL: 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 觸發(fā)

操作序列如下:

時間點 T1T2t1begin;
t2select * from idx where id = 1;
t3update 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;t8commit;

T1 執(zhí)行 commit 的時候會報錯:

16:07:50 [local:/data/run/pg12]:5120 pg12@testdb=#* commit;
ERROR: could not serialize access due to read/write dependencies among transactions
DETAIL: Reason code: Canceled on identification as a pivot, during commit attempt.
HINT: The transaction might succeed if retried.

感謝各位的閱讀,以上就是“PostgreSQL 禁止的異象是什么”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對 PostgreSQL 禁止的異象是什么這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是丸趣 TV,丸趣 TV 小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-07-27發(fā)表,共計2317字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 温宿县| 德惠市| 教育| 阿合奇县| 芜湖县| 尼勒克县| 武定县| 会泽县| 松滋市| 安图县| 任丘市| 资源县| 诸暨市| 镇坪县| 平阳县| 米林县| 视频| 新余市| 上栗县| 江口县| 通州区| 盱眙县| 铜鼓县| 平湖市| 句容市| 沧源| 甘孜| 安顺市| 桂平市| 东安县| 吉安市| 南投县| 五家渠市| 霍城县| 当阳市| 彩票| 株洲县| 郑州市| 喜德县| 龙岩市| 四川省|