Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJSSC-0005wb-Kx for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Sep 2020 02:18:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kJSSB-000609-If for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Sep 2020 02:18:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJSSB-000602-7H for pgsql-hackers@lists.postgresql.org; Sat, 19 Sep 2020 02:18:19 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kJSS7-0006rU-JU for pgsql-hackers@lists.postgresql.org; Sat, 19 Sep 2020 02:18:18 +0000 Received: by mail-io1-xd2b.google.com with SMTP id g7so9100113iov.13 for ; Fri, 18 Sep 2020 19:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=fORX/hezfsYeU8Slr7ssNVkonhtMl7eDGDyDGdzIUP0=; b=QhXJa6DwCoghFsycbkhQh7V1MVmh+0IM2BYwqEfXmowfEHdAo8SOYvBibLPBu0KWjB /R7P0wyi5hv/s8WkgyzjwVYag/Q1v0bWx8MqXuUgkg87J4WqqJgU+SrRG+ZwtQ1lSSQY AzJdCe43cxTIl54K6pP2J8jZkSTZiZuM0eGUbpi0ccitLKNosN0xl6HJtLH5QNd5ewWN vvnwLZ43+g+hz+uzJNOK7kPvuLBf7AeazY12Yd+FVPece3p1fPhKpvgrW+TOzAIC4YNA bD87YE7VBUpqgDdmBVZsLGrMHPMKyxfNV3ZvJ945XPBAaSOLkRGt7x1Orxw21RfdGJpP E9tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=fORX/hezfsYeU8Slr7ssNVkonhtMl7eDGDyDGdzIUP0=; b=e/vzenobNkr9ihpDVjchc9/aJmeWG3cpkk4Mz0lqstRrnAIZm1zFshXITCVD8g50ew ccTB3oQLADc33/dyO04I4Qs6a748+6AQW/CvBhq1VelPnGvg3R8/0UH29pBDYJWkXe8a meguW1sieX7B59KK1NgR+favNW1IYGe+VdB/oG9C4dJn7SztCirVFzXMRz4BS+L5ojUp vYd4bhE3xBe1+GOAoPCLpd0KnBwCdsC8skuU/ggyILxmRZu0DmHnVen45mUYOADDOFdb oJWjXF9Dn+Q8Gu7lZzS6c5n9S+lBu/WdE7yqTen9rMJi48RSM/9dLri2LG3iNExQmMJ1 T+lg== X-Gm-Message-State: AOAM533yCXhqTOQnaez2aHXE6JxmB8/3faC1KzdR7QgKiaVoc5OljWvX ZVdGGqVec7ibzDEXabfHzdQkxA== X-Google-Smtp-Source: ABdhPJw8wb4uHQv1AONvw7VOfh66LtswzXm4SVz1+l/Djy8vpid7XSRL/eqwrXFNkHbW5UzjCdomwA== X-Received: by 2002:a6b:2b07:: with SMTP id r7mr29545232ior.181.1600481893598; Fri, 18 Sep 2020 19:18:13 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id j20sm2649253ilq.6.2020.09.18.19.18.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Sep 2020 19:18:12 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 57F578007AB; Fri, 18 Sep 2020 21:18:11 -0500 (CDT) Date: Fri, 18 Sep 2020 21:18:11 -0500 From: Justin Pryzby To: Daniel Gustafsson Cc: Robert Haas , Magnus Hagander , Michael Paquier , Andres Freund , Tomas Vondra , Alvaro Herrera , pgsql-hackers@lists.postgresql.org Subject: Re: Online checksums patch - once again Message-ID: <20200919021811.GA30557@telsasoft.com> References: <85114708-887F-4A03-A57F-249F3E0009E3@yesql.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <85114708-887F-4A03-A57F-249F3E0009E3@yesql.se> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk + * 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