日本人妻巨大乳挤奶水免费,亚洲av之男人的天堂,日韩 欧美 动漫 国产 制服,川上奈美夫の上司に犯 在线观看

您的位置:首頁(yè) >觀察 > 正文

天天觀察:PostgreSQL的clog屬于日志還是數(shù)據(jù),需要遵守write-WAL-before-data嗎?


(資料圖片僅供參考)

總結(jié)

從原理上來看,MVCC需要給定事務(wù)ID后,能查詢到事務(wù)的狀態(tài)。

在PG中事務(wù)狀態(tài)可以從幾個(gè)路徑獲取:

在快照中查詢(活躍事務(wù))在元組頭的狀態(tài)為查詢(不活躍事務(wù))在CLOG中查詢(不活躍事務(wù))

如果不看實(shí)現(xiàn)只看概念,不活躍事務(wù)提交狀態(tài)也可以在XLOG中查詢,CLOG可以視作一種XLOG commit/rollback日志的緩存、映射,一種事務(wù)提交狀態(tài)的快速查詢方式。

所以在write-WAL-before-data中,CLOG也會(huì)按照data來處理,只有XLOG屬于WAL。

Postgresql中clog寫盤實(shí)現(xiàn)SlruPhysicalWritePage

postgresql中clog使用SLRU機(jī)制讀寫,在Slru寫盤前,會(huì)有保證xlog先寫的機(jī)制:

group_lsn表示32個(gè)事務(wù)一組中最大的日志序列號(hào)(LSN)。group_lsn主要用于事務(wù)提交非同步落盤的場(chǎng)景。
static boolSlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata){...if (shared->group_lsn != NULL){/* * We must determine the largest async-commit LSN for the page. This * is a bit tedious, but since this entire function is a slow path * anyway, it seems better to do this here than to maintain a per-page * LSN variable (which"d need an extra comparison in the * transaction-commit path). */XLogRecPtrmax_lsn;intlsnindex,lsnoff;lsnindex = slotno * shared->lsn_groups_per_page;max_lsn = shared->group_lsn[lsnindex++];for (lsnoff = 1; lsnoff < shared->lsn_groups_per_page; lsnoff++){XLogRecPtrthis_lsn = shared->group_lsn[lsnindex++];if (max_lsn < this_lsn)max_lsn = this_lsn;    <<<<<<<<<<<<<<<<<<<<<<<<< 找到最大的LSN}if (!XLogRecPtrIsInvalid(max_lsn)){/* * As noted above, elog(ERROR) is not acceptable here, so if * XLogFlush were to fail, we must PANIC.  This isn"t much of a * restriction because XLogFlush is just about all critical * section anyway, but let"s make sure. */START_CRIT_SECTION();XLogFlush(max_lsn);      <<<<<<<<<<<<<<<<<<<<<<<<< 先保證XLOG寫到這個(gè)位點(diǎn)!END_CRIT_SECTION();}}  ...  if (pg_pwrite(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)  {    ...  }}

Postgresql中用戶數(shù)據(jù)寫盤實(shí)現(xiàn)FlushBuffer

數(shù)據(jù)頁(yè)面同理,也是先找到頁(yè)面lsn,刷xlog,在寫數(shù)據(jù)。

static voidFlushBuffer(BufferDesc *buf, SMgrRelation reln){...buf_state = LockBufHdr(buf);/* * Run PageGetLSN while holding header lock, since we don"t have the * buffer locked exclusively in all cases. */recptr = BufferGetLSN(buf);   <<<<<<<<<<<<<<<<<<<<<<<<< 找到頁(yè)面的LSN/* To check if block content changes while flushing. - vadim 01/17/97 */buf_state &= ~BM_JUST_DIRTIED;UnlockBufHdr(buf, buf_state);/* * Force XLOG flush up to buffer"s LSN.  This implements the basic WAL * rule that log updates must hit disk before any of the data-file changes * they describe do. * * However, this rule does not apply to unlogged relations, which will be * lost after a crash anyway.  Most unlogged relation pages do not bear * LSNs since we never emit WAL records for them, and therefore flushing * up through the buffer LSN would be useless, but harmless.  However, * GiST indexes use LSNs internally to track page-splits, and therefore * unlogged GiST pages bear "fake" LSNs generated by * GetFakeLSNForUnloggedRel.  It is unlikely but possible that the fake * LSN counter could advance past the WAL insertion point; and if it did * happen, attempting to flush WAL through that location would fail, with * disastrous system-wide consequences.  To make sure that can"t happen, * skip the flush if the buffer isn"t permanent. */if (buf_state & BM_PERMANENT)XLogFlush(recptr);         <<<<<<<<<<<<<<<<<<<<<<<<< 先保證XLOG寫到這個(gè)位點(diǎn)!    ...smgrwrite(reln,  BufTagGetForkNum(&buf->tag),  buf->tag.blockNum,  bufToWrite,  false);  ...}

關(guān)鍵詞 PostgreSQL

熱門資訊

精品无人国产偷自产在线| 韩国a片巜上司与的人妻| 天黑黑影院免费观看视频在线播放| 亚洲和欧洲一码二码区别在| 免费a级毛片在线播放不收费| 免费国产黄网站在线观看动图| 欧美人与性动交Α欧美精品| 粗大的内捧猛烈进出在线视频| 人妻巨大乳hd免费看| 精品人妻无码一区二区三区下载| 免费追剧大全电视剧网站影视大全 | 97国产精华最好的产品| 亚洲av无码之国产精品| 亚洲av色情成人永久网站小说| 亚洲色素色无码专区| 国产毛片久久久久久国产毛片 | 人妻少妇看A偷人无码精品视频| 评书三国演义袁阔成播讲365集| 一本久道久久综合狠狠爱| 蜜臀av在线播放| 大屁股熟女一区二区三区| 九月婷婷人人澡人人添人人爽| 双乳被老汉揉搓a毛片免费观看| 中文字幕无码亚洲字幕成a人| 亚洲av永久无码精品一福利| 试看120秒做受小视频免费| 亚洲乱码无码永久不卡在线| 国产精品18久久久久久麻辣| 男人狂桶女人出白浆免费视频| 他揉捏她两乳不停呻吟a片| 青梅被从小摸到大h补课1视频| 国产一精品一av一免费爽爽| 少妇无码AV无码专区在线观看| 美女人体诱惑| 丰满少妇被猛烈高清播放| 久久人人爽人人爽人人片| 性无码专区无码| 国产免费久久精品国产传媒| 国产白丝jk捆绑束缚调教视频| 老熟妇高潮喷了╳╳╳| 国产chinasex对白videos麻豆|