這篇文章主要講解了“PostgreSQL禁止的異象是什么”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“PostgreSQL禁止的異象是什么”吧!
在旺蒼等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè) 網(wǎng)站設(shè)計(jì)制作按需網(wǎng)站制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),營(yíng)銷型網(wǎng)站,成都外貿(mào)網(wǎng)站建設(shè)公司,旺蒼網(wǎng)站建設(shè)費(fèi)用合理。
數(shù)據(jù)表idx,在id列上有索引,數(shù)據(jù)庫(kù)默認(rèn)的隔離級(jí)別為可串行化
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'
操作序列如下:
時(shí)間點(diǎn) | 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)在執(zhí)行update操作時(shí)會(huì)報(bào)錯(cuò)
-- 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=#!
操作序列如下:
時(shí)間點(diǎn) | 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)在執(zhí)行select操作時(shí)會(huì)報(bào)錯(cuò)
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=#!
操作序列如下:
時(shí)間點(diǎn) | 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執(zhí)行commit的時(shí)候會(huì)報(bào)錯(cuò):
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)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)PostgreSQL禁止的異象是什么這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
名稱欄目:PostgreSQL禁止的異象是什么
URL分享:http://www.rwnh.cn/article12/psghgc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開(kāi)發(fā)、云服務(wù)器、網(wǎng)站內(nèi)鏈、App設(shè)計(jì)、外貿(mào)網(wǎng)站建設(shè)、App開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)