Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jDlKf-0005Wo-N0 for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2020 08:42:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDlKe-00012V-Eb for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2020 08:42:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jDlKe-00012O-67 for pgsql-hackers@lists.postgresql.org; Mon, 16 Mar 2020 08:42:44 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jDlKc-0001BS-UY for pgsql-hackers@lists.postgresql.org; Mon, 16 Mar 2020 08:42:43 +0000 Received: by mail-wm1-x341.google.com with SMTP id m3so16974093wmi.0 for ; Mon, 16 Mar 2020 01:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=q5GGGPh/RT40MPJp2Vg5DWLgvfayDAoXCq9DPb5p03c=; b=NHhYSVM2MT22Osgz9Bsq4OGCPdCCRmkB3XXCSZrU5vXRLlLoyPSIzYhxAvObUMq9c+ llrThJG4w73vMWv6xjXhmYK2hkLYEk5L1ZD2NCeEyYADrQ+8ijaZSBUy9L7CQ94VcqWy RNWlXg1CxYhECFA2hfeDYcW5C6kHgfCxxC3LQoyA7NmzvoPk7GCMDAwAtLi8V6BssSHq b2ok4tNnnDve/N8aamwtir+0l2Itgj75cazrmU6NAjP7HziCGNnJ/shHVtWVqLweiiKu mwEOGfuYKLcXJJ8FEJTe8a7rXDLnO+JZMy6uyuWH7G852kwx/XrczVYM9eBx6D6q7Xxf eE6A== 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; bh=q5GGGPh/RT40MPJp2Vg5DWLgvfayDAoXCq9DPb5p03c=; b=WDQ2X3rKIGj0KEMMy5u39BE/884NuQFGMqrWdakn+zluOFMArG1i1WxEImnOmJgRAG zRTSo5Vf1+TKrKKbTiLFe1A5b6yf3wTOLB1g2XzAC7Una7rLq+qKNAyj1i+4/yO8ZIYk yxOruHcUXys2d9o1rO8gYsE5hEHnlAymGs/qGWzRGOoRGcbFh2SijlJFmN4UiywCJr/s YtMuv9WWoGzpwfIZP0DlFq04n2e5XlVUZAWIClTNOVjm/q+l2jNREejWNStfGhqVxvNO 1c3NDja9jCTSggm985kqSzn1d8sDVwBtIaP2xu8PUIXXas4G7J0Ddg1pXDS5h9ilLAH9 75sw== X-Gm-Message-State: ANhLgQ0H0BgnYvOMZAejCmnL7lnBQIP2/J0SA0mE0+n8hZyHHP5IyluL Fqly1FskFMZmeLn4I0WxwzU= X-Google-Smtp-Source: ADFU+vsFmYH9Jy+D1OvDwKwlOATWCB5m2k+toYMIcoBe47YdT9ZsO411BUo1jqG41sOXHMfxRRi6ig== X-Received: by 2002:a05:600c:2250:: with SMTP id a16mr17247512wmm.57.1584348162193; Mon, 16 Mar 2020 01:42:42 -0700 (PDT) Received: from nol (82-64-124-11.subs.proxad.net. [82.64.124.11]) by smtp.gmail.com with ESMTPSA id c26sm28491489wmb.8.2020.03.16.01.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 01:42:41 -0700 (PDT) Date: Mon, 16 Mar 2020 09:42:39 +0100 From: Julien Rouhaud To: Masahiko Sawada Cc: Michael Paquier , Robert Haas , PostgreSQL Hackers , Masahiko Sawada Subject: Re: Online checksums verification in the backend Message-ID: <20200316084239.4hc35bjmevzztcct@nol> References: <20191210022633.GD72921@paquier.xyz> <20200311071823.GA4643@nol> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Mar 16, 2020 at 01:53:35PM +0900, Masahiko Sawada wrote: > > In addition to comments from Michael-san, here are my comments: > > 1. > + if (!is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_SERVER_FILES)) > + ereport(ERROR, > + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), > + errmsg("only superuser or a member of the > pg_read_server_files role may use this function"))); Good point! I'll fix it. > + > + if (!DataChecksumsEnabled()) > + elog(ERROR, "Data checksums are not enabled"); > > I think it's better to reverse the order of the above checks. Indeed. > > 2. > +#define CRF_COLS 5 /* Number of output arguments in the SRF */ > > Should it be SRF_COLS? Oops, will fix. > > 3. > +static void > +check_delay_point(void) > +{ > + /* Always check for interrupts */ > + CHECK_FOR_INTERRUPTS(); > + > + /* Nap if appropriate */ > + if (!InterruptPending && VacuumCostBalance >= VacuumCostLimit) > + { > + int msec; > + > + msec = VacuumCostDelay * VacuumCostBalance / VacuumCostLimit; > + if (msec > VacuumCostDelay * 4) > + msec = VacuumCostDelay * 4; > + > + pg_usleep(msec * 1000L); > + > + VacuumCostBalance = 0; > + > + /* Might have gotten an interrupt while sleeping */ > + CHECK_FOR_INTERRUPTS(); > + } > +} > > Even if we use vacuum delay for this function, I think we need to set > VacuumDelayActive and return if it's false, or it's better to just > return if VacuumCostDelay == 0. Good point, I'll fix that. > > 4. > +static void > +check_all_relations(TupleDesc tupdesc, Tuplestorestate *tupstore, > + ForkNumber forknum) > > I also agree with Michael-san to remove this function. Instead we can > check all relations by: > > select pg_check_relation(oid) from pg_class; Sure, but ideally we should do that in a client program (eg. pg_checksums) that wouldn't maintain a transaction active for the whole execution. > 6. > Other typos > > s/dirted/dirtied/ > s/explictly/explicitly/ Will fix, thanks!