SingleWrite vs TripleWrite

允我心安 提交于 2019-12-24 03:47:10

问题


I have a fairly good grasp on when and where using SingleWrite can be advantageous as a log algorithm in MQ. It benefits high throughput, low concurrency workloads. When the work load is more concurrent, TripleWrite's overhead is less of a factor.

What I don't understand and am struggling to find ANY information about is how TripleWrite (the default for Websphere MQ since v6) is actually implemented. I know it doesn't actually write every transaction to the log three times, and that it only behaves differently from SingleWrite when partial pages are concerned. But what does it do differently? Does it call fsync three times?

I don't have any real practical purpose or problem to solve, this is more curiosity than anything. I've been working with Websphere MQ for a couple of years and would like to understand this better.

Is anyone able to shed any light?

Edit:

I've thought about it some more and one of the options is that it is something similar to InnoDB's DoubleWrite. InnoDB has a double write buffer that all changes are written to first sequentially, before the updates are written to the data file. On recovery either you have a complete successfully written double write buffer to recover from, or the table data was never modified.

I am not sure if this is similar to MQ's TripleWrite because it has been asserted in several different instances that TripleWrite does not repetitively write all the pages, and that TripleWrite only behaves differently from SingleWrite when applied to partial pages.


回答1:


Very roughly speaking its something like the following (Remember the issue is only ever about partial pages which are less and less likely as you move up releases of MQ - that's why the benefit of single write is very minimal mostly)

Imagine MQ wrote 10 bytes into a page, so has lots of space left in the log page (which are fixed sizes). When MQ then wants to write more bytes (either the rest of the page now the logger has moved on, or potentially (less likely) a small amount more data), it cant just write over that page as the disk may crash mid write and would potentially corrupt what was already needed to preserve to maintain integrity (the first 10 bytes). Hence the 2nd write (with more data) occurs elsewhere and is followed by a 3rd write which goes over the original page. Because it always know which writes were successful, it knows whether the original page or the 'elsewhere' page should be used during the recovery step.



来源:https://stackoverflow.com/questions/29296196/singlewrite-vs-triplewrite

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!