Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t0EOp-00A9hp-DD for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Oct 2024 06:17:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t0EOn-00ARRx-K1 for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Oct 2024 06:17:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t0EOn-00ARRo-6Q for pgsql-hackers@lists.postgresql.org; Mon, 14 Oct 2024 06:17:45 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t0EOk-000mvk-Ny for pgsql-hackers@lists.postgresql.org; Mon, 14 Oct 2024 06:17:44 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-37d6a2aa748so639556f8f.1 for ; Sun, 13 Oct 2024 23:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728886660; x=1729491460; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Kw43CC4RwU4HDYBRWFfcROvNpqu3/QhQDMqFSU1tNKA=; b=PLc6ZI8PXqdEB9iVi2gEi2abP7cgCZLQyQ13wyymwPsRtXHo1giTRRxjzwxxlwu4Vk RC7oUltlTt0GuhIdK6sv7KF/pzKvGD/MLi3GTZzl6ERmOHO+Vix35kjDuOUtTxIxlIA7 n5iaavJRnab/HCuuHZhiuk7otGNRBWZTODI4E7syFZHKSLdXbfXFCWvi3rV0t3NV3keU e//t17mPpoGq3ctD4TKzQJjDq8JLdv76pzVbyb7quiJ5aqLPE01LqUu5amhgq0HxEPYr q+56FS6ONaibyBwb5PnWtkcKfWe3FBxUubumnFV0C1qNanwZiy9YSs00X01T92CpLhXB OtDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728886660; x=1729491460; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Kw43CC4RwU4HDYBRWFfcROvNpqu3/QhQDMqFSU1tNKA=; b=IxWwwgOxWU9roNHcXhHMBW/KanGu1xrc58QlpjRTXatqFdhjHvBJa//20KcYu7Gn/c BwZlaDYEeBfeWkkb5HlBmrJeLWjqsqV/z4mVsJVM5GRfQNxu8hp+xzxYBlFNTt2jM8si IJjXmgO+Hh1cyD2IR2GoA/xNui4V4oSryyFd+t86TXw2H5p1/x2ewLv4GsKcQbKO9+Ov Z40tCQ5chRFeAbmdD6Pgqa4Y0OsofNLDHI5mgYKT5XndhllCeMBrXnkpj7/skbWELl3t 1WtlN53wvLh7OPgeOftO6MM2YGYJBdp5icQW8ePifkZ04O0Wvs4jbXFfTTQobe2cUV0Z MKsA== X-Forwarded-Encrypted: i=1; AJvYcCXqPC64q2Sq0FcWVDgndPxOzvN4/aSn5naRgMGeGZSg2HOAWl5+Wo3V3Itv3WhKMVujI79japytzNZZtHg4@lists.postgresql.org X-Gm-Message-State: AOJu0YySFKUUFFOI5lDLAnekwuhxIK3G1IrZYvpoPwaiF/gqw9pXPmXL 6UL4Qb9S3z+kb1l5QzQiJsambq3eJ8awbuVZHtm2dX28FOAMCKKq X-Google-Smtp-Source: AGHT+IHNWk1wmiSRV4XMDtWivU43BsflSgTgTJcLbH+XtbtAjgFPBxmozHlfbG43rCHFGLvcN2k4vw== X-Received: by 2002:a5d:69c6:0:b0:37d:3985:8871 with SMTP id ffacd0b85a97d-37d5ffc02a8mr5284161f8f.39.1728886660023; Sun, 13 Oct 2024 23:17:40 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b7ef2a5sm10403257f8f.106.2024.10.13.23.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 23:17:39 -0700 (PDT) Date: Mon, 14 Oct 2024 06:17:38 +0000 From: Bertrand Drouvot To: Masahiko Sawada Cc: Peter Smith , Peter Eisentraut , shveta malik , Amit Kapila , Bharath Rupireddy , pgsql-hackers@lists.postgresql.org Subject: Re: Add contrib/pg_logicalsnapinspect Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Fri, Oct 11, 2024 at 04:48:26PM -0700, Masahiko Sawada wrote: > On Fri, Oct 11, 2024 at 11:15 AM Masahiko Sawada wrote: > > > > On Fri, Oct 11, 2024 at 6:15 AM Bertrand Drouvot > > wrote: > > > > > > Hi, > > > > > > On Thu, Oct 10, 2024 at 05:38:43PM -0700, Masahiko Sawada wrote: > > > > On Thu, Oct 10, 2024 at 6:10 AM Bertrand Drouvot > > > > wrote: > > > > > > > > The patches mostly look good to me. Here are some minor comments: > > > > > > Thanks for looking at it! > > > > > > > > > > > + sprintf(path, "%s/%s", > > > > + PG_LOGICAL_SNAPSHOTS_DIR, > > > > + text_to_cstring(filename_t)); > > > > + > > > > + /* Validate and restore the snapshot to 'ondisk' */ > > > > + ValidateAndRestoreSnapshotFile(&ondisk, path, > > > > CurrentMemoryContext, false); > > > > + > > > > + /* Build a tuple descriptor for our result type */ > > > > + if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) > > > > + elog(ERROR, "return type must be a row type"); > > > > + > > > > I think it would be better to check the result type before reading the > > > > snapshot file. > > > > > > Agree, done in v14. > > > > > > > > > > > --- > > > > + values[i++] = Int64GetDatum((int64) ondisk.checksum); > > > > > > > > Why is only checksum casted to int64? With that, it can show a > > > > checksum value as a non-netagive integer but is it really necessary? > > > > For instance, page_header() function in pageinspect shows a page > > > > checksum as smallint. > > > > > > Yeah, pd_checksum in PageHeaderData is uint16 while checksum in SnapBuildOnDisk > > > is pg_crc32c. The reason why it is casted to int64 is explained in [1], does that > > > make sense to you? > > > > In the email, you said: > > > > > As the checksum could be > 2^31 - 1, then v9 (just shared up-thread) changes it > > > to an int8 in the pg_logicalinspect--1.0.sql file. So, to avoid CI failure on > > > the 32bit build, then v9 is using Int64GetDatum() instead of UInt32GetDatum(). > > > > I'm fine with using Int64GetDatum() for checksum. > > > > > > > > > Same goes for below: > > > > values[i++] = Int32GetDatum(ondisk.magic); > > > > values[i++] = Int32GetDatum(ondisk.magic); > > > > > > The 2 others field (magic and version) are unlikely to be > 2^31 - 1, so v9 is > > > making use of UInt32GetDatum() and keep int4 in the sql file. > > > > While I agree that these two fields are unlikely to be > 2^31 - 1, I'm > > concerned a bit about an inconsistency that the patch uses > > Int64GetDatum also for both ondisk.builder.committed.xcnt and > > ondisk.builder.catchange.xcnt. Thanks for the feedback. That makes sense and I agree with the proposal done in v15. > > > > I have a minor comment: > > > > + > > + General Functions > > > > If we use "General Functions" here it sounds like there are other > > functions for specific purposes in pg_logicalinspect module. How about > > using "Functions" instead? > > To elaborate further, pageinspect has a "General Functions" section, > which makes sense to me as it has other AM-type specific functions. On > the other hand, pg_logicalinspect has SQL functions only for one > logical replication component. So I think it makes sense to use > "Function" instead. pg_walinspect also has the sole section "General > Function" Yeah, I used it as a "template". > but I personally think that "Function" is more appropriate > like other modules does. I do agree. > BTW I think that adding snapshot_internal.h could be a separate patch. > That makes the main pg_logicalinspect patch cleaner. Agree. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com