Hi!

I've noticed two bugs reported [0] and [1] which are both related to the
wraparound of mxid and
mxoff. Problems for mxid and mxoff are minor, as they require hitting the
exact overflow limit to
occur. But it's better to correct it.

I included a test to reproduce the problem (see 0001). It is not intended
to be committed, I
guess. I then added a commit with a fix.

There two fixes.
1) pg_upgrade does not consider the mxid to be in a wraparound state. In
this case, I adjust
    the mxid value to the FirstMultiXactId. Alternatively, it might be
conceivable to include the
    ability to set InvalidMultiXactId in pg_resetwal, but this seems odd to
me.
2) pg_resetwall forbids to set mxoff to UINT_MAX32. I'm not sure if this
was done on
    purpose or not, but perhaps this check can be removed.

Here is what I've got with the fix applied.

>>> before upgrade:
Latest checkpoint's NextMultiXactId:  0
Latest checkpoint's NextMultiOffset:  4294967295
Latest checkpoint's oldestMultiXid:   4294967295

>>> after upgrade:
Latest checkpoint's NextMultiXactId:  1
Latest checkpoint's NextMultiOffset:  4294967295
Latest checkpoint's oldestMultiXid:   4294967295

Thoughts?

[0]
https://www.postgresql.org/message-id/18863-72f08858855344a2%40postgresql.org
[1]
https://www.postgresql.org/message-id/18865-d4c66cf35c2a67af%40postgresql.org

-- 
Best regards,
Maxim Orlov.

Attachment: v1-0001-Test-case-for-BUG-18863-and-BUG-18865.patch
Description: Binary data

Attachment: v1-0002-Fix-the-mxid-and-mxoff-wraparound-issues-in-pg_up.patch
Description: Binary data

Reply via email to