pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: John Naylor <johncnaylorls@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Nathan Bossart <nathandbossart@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: Yura Sokolov <y.sokolov@postgrespro.ru>
Subject: Re: [PoC] Improve dead tuple storage for lazy vacuum
Date: Sun, 24 Mar 2024 12:53:36 -0400
Message-ID: <2089517.1711299216@sss.pgh.pa.us> (raw)
In-Reply-To: <CANWCAZb76qEZZ_L=V7M2ByEmeeFqzkoFT27-G+q-RdccOmtFBg@mail.gmail.com>
References: <CAFBsxsGW_aMSw0Odpd=T1UGRyfX2CdjdVqCNBMik-wfnGC0vAA@mail.gmail.com>
	<CAD21AoAyxDaNrvWwSVfPerQkP034FG0PjYb=7j51QVTiPAtqgQ@mail.gmail.com>
	<CAFBsxsFm1eNPv-_Z2-Gy0aFMMiqgvNym3ojwK0scbEaBbW4FHw@mail.gmail.com>
	<CAD21AoB9M2Faw7K9CLON41iT6eXoC_YwTcKJ1V4Z33J0o0MySg@mail.gmail.com>
	<CAD21AoA4QZ6uTksTzneO7WGXQ-0jnfv=4mGLfgF7V9tdNgV11Q@mail.gmail.com>
	<CAFBsxsFV=-ER1GYzXkBnS68imeoAdAS69vEvMsrVpBhYFNopHg@mail.gmail.com>
	<CAD21AoD3w76wERs_Lq7_uA6+gTaoOERPji+Yz8Ac6aui4JwvTg@mail.gmail.com>
	<CAFBsxsHbvfdMe7qranpiEwaWPwTY97EgM9mXnCEj9gTo6BY=UA@mail.gmail.com>
	<CAD21AoCCQ7T1XNCKtnNe+qiqsdgMsmZsugDpbYQdBVCAi5=zgg@mail.gmail.com>
	<CAFBsxsGCW=CfgzatJOQ9iuz5UbrMaqPNpP7UZ-ON+2Pgh=zCwg@mail.gmail.com>
	<20220921180126.GA453160@nathanxps13>
	<CAFBsxsFk7btGg8G_Yjy76be8AJ9PKZH677zK5NKx4uL2EPRtcg@mail.gmail.com>
	<CAFBsxsF6OT+4Hkjm3J1+qtE_OuegWO3D-UQ5hO0krTTrRZ=8hw@mail.gmail.com>
	<CAD21AoBBF5Cr6Y+scEzoAcPQt6UQqwMaGnCODKvj+=CMUsY-Tw@mail.gmail.com>
	<CAFBsxsG2SDMpmON_ovVY6S+oCT-Mn=9giMm4_Yqu! HdkZfn7XBQ@mail.gmail.com>
	<CAD21AoDg8S1QP-YR4132oPazPSvhdn-uArDF1AGEQiAYKhHfqA@mail.gmail.com>
	<CAFBsxsFEVckVzsBsfgGzGR4Yz=Jp=UxOtjYvTjOz6fOoLXtOig@mail.gmail.com>
	<CAFBsxsHDNrNSK4PDfKDArzVDEE2zozgMQZ0NbwMJmOfAC-xhbA@mail.gmail.com>
	<CAFBsxsFPs258sP1E9oMT2EN3GJtMB7O8ZKrSDnsA0qdf1nFbcg@mail.gmail.com>
	<CAD21AoB+z3+T2EnOBVXok2aeRywrDZDFkwwEaWKZSrFz9s1+mw@mail.gmail.com>
	<CAFBsxsEunCjqXo6Q1rjw6fqmduh5DncTDaDw0NhLr2fYBQTj3w@mail.gmail.com>
	<CAD21AoAT0p0crCjiY+UwXbkQG2bRNFbe0UF0Ba5EfC_w458JBQ@mail.gmail.com>
	<CAFBsxsGV9ssgP-itGa_TVux0v=_B16-28ff+q_G2WLCgBstSLg@mail.gmail.com>
	<CAD21AoBp2ErXCc01t0+jwBrNjRA=FkKPz1-yNNFcNC-PRsG5TA@mail.gmail.com>
	<CAFBsxsG9NmS=XKtofS5sxddsA64RVLkYnQ4+8pbXkwADGDGjoQ@mail.gmail.com>
	<CAD21AoB8oE4WtgXhs+YFwOH3ODAOvEN48afFLYL=vqMk0d25TA@mail.gmail.com>
	<CAD21AoCLvVkvf=0Jyu+wV9=GZTcEva+R0q-FzMU9viT9asoevA@mail.gmail.com>
	<CAFBsxsF67qpj16kRitgRLJFw=omWsWNwCkaJmNJM9PWvZ4zBLA@mail.gmail.com>
	<CAFBsxsHgP5LP9q=Rq_3Q2S6Oyut67z+Vpemux+KseSPXhJF7sg@mail.gmail.! com>
	<CAFBsxsHdKnkSzyKwEgzL16-FQCEHuQ1jT5T6L=28DWT_sMfgPg@mail.gmail.com>
	<CAD21AoDyJWxmPJ8cZj3Y8P1o6EEjjkbmgho4Jb2ABjfhc19Kkw@mail.gmail.com>
	<CAFBsxsFSSXCyU1RtGi1EpONi+QRpurrgnwHR8mNK8Wgi=Stgvg@mail.gmail.com>
	<CAFBsxsFMuyUd48SXy1VMFvpVBHh6B6300_UfTSiPckKJtcwWMA@mail.gmail.com>

John Naylor <johncnaylorls@gmail.com> writes:
> Done. I pushed this with a few last-minute cosmetic adjustments. This
> has been a very long time coming, but we're finally in the home
> stretch!

I'm not sure why it took a couple weeks for Coverity to notice
ee1b30f12, but it saw it today, and it's not happy:

/srv/coverity/git/pgsql-git/postgresql/src/include/lib/radixtree.h: 1621 in local_ts_extend_down()
1615     		node = child;
1616     		shift -= RT_SPAN;
1617     	}
1618     
1619     	/* Reserve slot for the value. */
1620     	n4 = (RT_NODE_4 *) node.local;
>>>     CID 1594658:  Integer handling issues  (BAD_SHIFT)
>>>     In expression "key >> shift", shifting by a negative amount has undefined behavior.  The shift amount, "shift", is as little as -7.
1621     	n4->chunks[0] = RT_GET_KEY_CHUNK(key, shift);
1622     	n4->base.count = 1;
1623     
1624     	return &n4->children[0];
1625     }
1626     

I think the point here is that if you start with an arbitrary
non-negative shift value, the preceding loop may in fact decrement it
down to something less than zero before exiting, in which case we
would indeed have trouble.  I suspect that the code is making
undocumented assumptions about the possible initial values of shift.
Maybe some Asserts would be good?  Also, if we're effectively assuming
that shift must be exactly zero here, why not let the compiler
hard-code that?

-     	n4->chunks[0] = RT_GET_KEY_CHUNK(key, shift);
+     	n4->chunks[0] = RT_GET_KEY_CHUNK(key, 0);

			regards, tom lane





view thread (462+ messages)  latest in thread

Message-ID: <2089517.1711299216@sss.pgh.pa.us>
Permalink:  ../2089517.1711299216@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2089517.1711299216@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, johncnaylorls@gmail.com, sawada.mshk@gmail.com, nathandbossart@gmail.com, andres@anarazel.de, boekewurm+postgres@gmail.com, y.sokolov@postgrespro.ru
  Subject: Re: [PoC] Improve dead tuple storage for lazy vacuum
  In-Reply-To: <2089517.1711299216@sss.pgh.pa.us>
  References: <CAFBsxsGW_aMSw0Odpd=T1UGRyfX2CdjdVqCNBMik-wfnGC0vAA@mail.gmail.com> <CAFBsxsEunCjqXo6Q1rjw6fqmduh5DncTDaDw0NhLr2fYBQTj3w@mail.gmail.com> <CAD21AoAT0p0crCjiY+UwXbkQG2bRNFbe0UF0Ba5EfC_w458JBQ@mail.gmail.com> <CAFBsxsGV9ssgP-itGa_TVux0v=_B16-28ff+q_G2WLCgBstSLg@mail.gmail.com> <CAD21AoBp2ErXCc01t0+jwBrNjRA=FkKPz1-yNNFcNC-PRsG5TA@mail.gmail.com> <CAFBsxsG9NmS=XKtofS5sxddsA64RVLkYnQ4+8pbXkwADGDGjoQ@mail.gmail.com> <CAD21AoB8oE4WtgXhs+YFwOH3ODAOvEN48afFLYL=vqMk0d25TA@mail.gmail.com> <CAD21AoCLvVkvf=0Jyu+wV9=GZTcEva+R0q-FzMU9viT9asoevA@mail.gmail.com> <CAFBsxsF67qpj16kRitgRLJFw=omWsWNwCkaJmNJM9PWvZ4zBLA@mail.gmail.com> <CAFBsxsHdKnkSzyKwEgzL16-FQCEHuQ1jT5T6L=28DWT_sMfgPg@mail.gmail.com> <CAD21AoDyJWxmPJ8cZj3Y8P1o6EEjjkbmgho4Jb2ABjfhc19Kkw@mail.gmail.com> <CAFBsxsFSSXCyU1RtGi1EpONi+QRpurrgnwHR8mNK8Wgi=Stgvg@mail.gmail.com> <CAFBsxsFMuyUd48SXy1VMFvpVBHh6B6300_UfTSiPckKJtcwWMA@mail.gmail.com> <2089517.1711299216@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox