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 1nbWwe-0002iQ-N6 for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Apr 2022 00:21:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbWwd-00020r-FE for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Apr 2022 00:21:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbWwc-00020h-Tu for pgsql-hackers@lists.postgresql.org; Tue, 05 Apr 2022 00:21:15 +0000 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nbWwa-000118-JC for pgsql-hackers@postgresql.org; Tue, 05 Apr 2022 00:21:13 +0000 Received: by mail-qt1-x835.google.com with SMTP id v2so9223066qtc.5 for ; Mon, 04 Apr 2022 17:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=eyQ93V68mNDbR+HzNwAcpubD1rh/1F3rlqyGKx3dQ+U=; b=PsUAdONIAifF6/mr41klmpJk4FyBiQwdlfTzt1qTOAhC90XWQNp0G3wfByGM4gHoaP GYsLvUeo5oL0vos/5CxNKvxR1k7DMMCm35YbHobHvzSwPKFnEQPgwxNdAoinNMJJNudq erpJw2/6eUNtbFzBuXT8VD8TLf186mT4U32Dg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=eyQ93V68mNDbR+HzNwAcpubD1rh/1F3rlqyGKx3dQ+U=; b=Ro++eFOkFJZOaC2qiOlmmcpclw6/6qxIK+H3MZzXlkkt0XRsV6GyeTevvtDtlrJEbg zTfJ5rt6fUF/T7eTcbQqF4hFnlsfPH1+AJYtcYO+MznJDUML09H9a10GGlT4JNp4SHwW mOO3dtbKqibrf0+8f0XRR4S1IrPwb/p9ds5ztD+uwPhrtgSTnwFnBwyP/i0VjWZHjyhl Tsvy2cPMqD7p+TRL+E84YZHr4rGHwMU8Y4d/QR9bwFkhVRyvBJh+wfOt0/8Rdex584Wu e8xH8QItDmqUEKmqu6kZTHMpEXDlKLxMYDL2CVLO5BfM6RQq4Fb0RuQ4wXNbLlBd/1O3 yyHg== X-Gm-Message-State: AOAM531LnFHfrI9bNV3DW0AiGmhCM8qbAKNfzdO60fqaY8vTu8FEMsh2 qlIEko/bCPYPcTGId101pSBw/Q== X-Google-Smtp-Source: ABdhPJxwS8AZ2JejKlrrvVBv3BQw7YZn/IqVlZI9pTsU0z3tZOZVGa0SoiYWOoVUi9Ft5uPrfbYwXQ== X-Received: by 2002:a05:622a:11d2:b0:2e0:bbbd:5a2b with SMTP id n18-20020a05622a11d200b002e0bbbd5a2bmr841789qtk.233.1649118071743; Mon, 04 Apr 2022 17:21:11 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::2e]) by smtp.gmail.com with ESMTPSA id a23-20020a05620a16d700b0067e98304705sm6810227qkn.89.2022.04.04.17.21.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Apr 2022 17:21:11 -0700 (PDT) Date: Mon, 4 Apr 2022 17:21:07 -0700 From: Noah Misch To: Masahiko Sawada Cc: Amit Kapila , Euler Taveira , "osumi.takamichi@fujitsu.com" , Peter Eisentraut , "David G. Johnston" , "tanghy.fnst@fujitsu.com" , vignesh C , Greg Nancarrow , "houzj.fnst@fujitsu.com" , Alexey Lesovsky , pgsql-hackers Subject: Re: Skipping logical replication transactions on subscriber side Message-ID: <20220405002107.GA3827588@rfd.leadboat.com> References: <20220402081346.GD3719101@rfd.leadboat.com> <20220403004555.GA3759211@rfd.leadboat.com> <20220404023128.GA3799006@rfd.leadboat.com> <20220404062620.GE3799006@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Apr 04, 2022 at 06:55:45PM +0900, Masahiko Sawada wrote: > On Mon, Apr 4, 2022 at 3:26 PM Noah Misch wrote: > > On Mon, Apr 04, 2022 at 08:20:08AM +0530, Amit Kapila wrote: > > > How about a comment like: "It has to be kept at 8-byte alignment > > > boundary so as to be accessed directly via C struct as it uses > > > TYPALIGN_DOUBLE for storage which has 4-byte alignment on platforms > > > like AIX."? Can you please suggest a better comment if you don't like > > > this one? > > > > I'd write it like this, though I'm not sure it's an improvement on your words: > > > > When ALIGNOF_DOUBLE==4 (e.g. AIX), the C ABI may impose 8-byte alignment on > > some of the C types that correspond to TYPALIGN_DOUBLE SQL types. To ensure > > catalog C struct layout matches catalog tuple layout, arrange for the tuple > > offset of each fixed-width, attalign='d' catalog column to be divisible by 8 > > unconditionally. Keep such columns before the first NameData column of the > > catalog, since packagers can override NAMEDATALEN to an odd number. > > Thanks! > > > > > The best place for such a comment would be in one of > > src/test/regress/sql/*sanity*.sql, next to a test written to detect new > > violations. > > Agreed. > > IIUC in the new test, we would need a new SQL function to calculate > the offset of catalog columns including padding, is that right? Or do > you have an idea to do that by using existing functionality? Something like this: select attrelid::regclass, attname, array(select typname from pg_type t join pg_attribute pa on t.oid = pa.atttypid where pa.attrelid = a.attrelid and pa.attnum > 0 and pa.attnum < a.attnum order by pa.attnum) AS types_before, (select sum(attlen) from pg_type t join pg_attribute pa on t.oid = pa.atttypid where pa.attrelid = a.attrelid and pa.attnum > 0 and pa.attnum < a.attnum) AS len_before from pg_attribute a join pg_class c on c.oid = attrelid where attalign = 'd' and relkind = 'r' and attnotnull and attlen <> -1 order by attrelid::regclass::text, attnum; attrelid │ attname │ types_before │ len_before ─────────────────┼──────────────┼─────────────────────────────────────────────┼──────────── pg_sequence │ seqstart │ {oid,oid} │ 8 pg_sequence │ seqincrement │ {oid,oid,int8} │ 16 pg_sequence │ seqmax │ {oid,oid,int8,int8} │ 24 pg_sequence │ seqmin │ {oid,oid,int8,int8,int8} │ 32 pg_sequence │ seqcache │ {oid,oid,int8,int8,int8,int8} │ 40 pg_subscription │ subskiplsn │ {oid,oid,name,oid,bool,bool,bool,char,bool} │ 81 (6 rows) That doesn't count padding, but hazardous column changes will cause a diff in the output.