pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Justin Pryzby <pryzby@telsasoft.com>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Magnus Hagander <magnus@hagander.net>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Andres Freund <andres@anarazel.de>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Online checksums patch - once again
Date: Fri, 18 Sep 2020 21:18:11 -0500
Message-ID: <20200919021811.GA30557@telsasoft.com> (raw)
In-Reply-To: <85114708-887F-4A03-A57F-249F3E0009E3@yesql.se>
References: <CA+Tgmoa_WTE6WGn7P05TeOCRO82d+mVg+TaLSe0xjd56WhOQmA@mail.gmail.com>
	<CABUevEwns5iuvJ_kH_9KXNyo3Z8=RHB-DM1-TKP26yoVo0=xvg@mail.gmail.com>
	<CA+TgmoZrwxbra85d7tjgT9CmrT3H5iHGTi40A=6gcReN7WgnHg@mail.gmail.com>
	<CABUevEzZcmyOHXNV91BHpFmM3Bm5wKsZUcUOUVqsh-Or6EJpTA@mail.gmail.com>
	<CA+TgmoY61f+dywbWvFCfReJP-yO5ey7Liv44j6f6oWJCX=fbYg@mail.gmail.com>
	<A5CA3D81-9C8A-4D04-987D-1BEB0559B3D3@yesql.se>
	<CA+TgmoaryNACeLnLpfhx==gYy1+59VhMtrWspcZGay9eDvYHMw@mail.gmail.com>
	<AE4A785C-607C-4059-96DB-E4952E7449DA@yesql.se>
	<CA+TgmoZV+gvfQd6O6KXW=yYVC2nUafs6cgFP1ZC_+w2qyM6POg@mail.gmail.com>
	<85114708-887F-4A03-A57F-249F3E0009E3@yesql.se>

+ * changed to "inprogress-off", the barrier for mvoving to "off" can be
moving

+ * When disabling checksums, data_checksums will be set of "inprogress-off"
set *to*

+	get_namespace_name(RelationGetNamespace(reln)), RelationGetRelationName(reln),

I think this palloc()s a new copy of the namespace every 100 blocks.
Better do it outside the loop.

+	{"inprogress-on", DATA_CHECKSUMS_INPROGRESS_ON, true},
+	{"inprogress-off", DATA_CHECKSUMS_INPROGRESS_OFF, true},

enabling / disabling ?

+typedef enum ChecksumType
+{
+	DATA_CHECKSUMS_OFF = 0,
+	DATA_CHECKSUMS_ON,
+	DATA_CHECKSUMS_INPROGRESS_ON,
+	DATA_CHECKSUMS_INPROGRESS_OFF
+}			ChecksumType;

Should this be an bitmask, maybe
DATA_CHECKSUMS_WRITE = 1 
DATA_CHECKSUMS_VERIFY = 2,

It occured to me that you could rephrase this patch as "Make checksum state
per-relation rather than cluster granularity".  That's currently an
implementation detail, but could be exposed as a feature.  That could be a
preliminary 0001 patch.  Half the existing patch would be 0002 "Allow
online enabling checksums for a given relation/database/cluster".  You might
save some of the existing effort of synchronize the cluster-wide checksum
state, since it doesn't need to be synchronized.  The "data_checksums" GUC
might be removed, or changed to an enum: on/off/per_relation.  Moving from
"per_relation" to "on" would be an optional metadata-only change, allowed only
when all rels in all dbs are checksumed.  I'm not sure if you'd even care about
temp tables, since "relhaschecksum" would be authoritative, rather than a
secondary bit only used during processing.

XLogHintBitIsNeeded() and DataChecksumsEnabled() would need to check
relhaschecksum, which tentatively seems possible.

I'm not sure if it's possible, but maybe pg_checksums would be able to skip
rels which had already been checksummed "online" (with an option to force
reprocessing).

Maybe some people would want (no) checksums on specific tables, and that could
eventually be implemented as 0003: "ALTER TABLE SET checksums=".  I'm thinking
of that being used immediately after an CREATE, but I suppose ON would cause
the backend to rewrite the table with checksums synchronously (not in the BGW),
either with AEL or by calling ProcessSingleRelationByOid().

-- 
Justin





view thread (87+ messages)  latest in thread

Message-ID: <20200919021811.GA30557@telsasoft.com>
Permalink:  ../20200919021811.GA30557@telsasoft.com/
Also on:    postgresql.org/message-id/20200919021811.GA30557@telsasoft.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: pryzby@telsasoft.com, daniel@yesql.se, robertmhaas@gmail.com, magnus@hagander.net, michael@paquier.xyz, andres@anarazel.de, tomas.vondra@2ndquadrant.com, alvherre@2ndquadrant.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Online checksums patch - once again
  In-Reply-To: <20200919021811.GA30557@telsasoft.com>

* 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