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 1s8Rse-00Cj5M-Qf for pgsql-hackers@arkaria.postgresql.org; Sat, 18 May 2024 21:46:18 +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 1s8Rsd-00AMl5-R0 for pgsql-hackers@arkaria.postgresql.org; Sat, 18 May 2024 21:46:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s8Rsd-00AMkw-GP for pgsql-hackers@lists.postgresql.org; Sat, 18 May 2024 21:46:15 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s8RsZ-000w5t-69 for pgsql-hackers@lists.postgresql.org; Sat, 18 May 2024 21:46:14 +0000 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7e1ae7cc420so107440539f.2 for ; Sat, 18 May 2024 14:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1716068770; x=1716673570; darn=lists.postgresql.org; h=user-agent: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=UCIDIGPgcHclDoxj38/QJ5BAH695RKcTtDIYvcHScrs=; b=NSYwdJaZW3NkBMt+r3zfxMiwl5Kk27icSSF1UsIxP5JVDRNyPAqb6sLIbbEb4Ua1cf gHZJdO3k5Gq+iUl5ZGWal7RRrkh9zVwHzrsORgbAHN69uwAsH0FeIgIA87SkMrhGZ5Bz sc9j4SiOnZQ6UG4Q4q3Zi2NMQkE8Y9cl+sszA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716068770; x=1716673570; h=user-agent: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=UCIDIGPgcHclDoxj38/QJ5BAH695RKcTtDIYvcHScrs=; b=rFE/FwkkkepN5KpBkLXbnVrBAsBckq0keOA/Aq+tRFfdl+kQ/G/53r9AAU7JQuAmVB WH38pNnoYieXA/cVjvdUGqLuYI+tVMgC6ZxxGwHthtqYudu4JwOaLvVh1Jzd/iH6X9A/ wyCUlwEfAWuEW2LPRTNhDXruyefVT5SusBefpn7GAAxYgUy15Td9B4xCWVp/aFjpfLlx Pycft8cwRSukpJzfefs2W9tkBI2ZfvSk2vIYbZmsx6pJnV2dKtOu7t49xJjtkmrJjKSm 1LNSUUgWtRsHRJCwbreBrnttGnIUSmE4hEdb0u5qUeKVbeVqvyYSrPKdf6bfdIlSSUYE skEg== X-Forwarded-Encrypted: i=1; AJvYcCVgwfrSWeTEEPZcLrDCx9vaOqh6OhCkhlCVBie5mwlgTbcYksKiZyGIe2onH3L7QI1eDYrSdr5w2fUpjnF03FQiwM+zjBApivgbFnDmEc3rryal X-Gm-Message-State: AOJu0Yxg8S2sLFxZBTocgZbhUJ+UlRzw7Ze11GGao8FfenM/SIQlLP+H dTFyBhBPdVTlELv9i8cv3QfgtjJK8OaK2QXZPMYCA8FC2yyYyKrzumfinHpRzWW4YpDCWM8cE+e kLw== X-Google-Smtp-Source: AGHT+IESFKsTJqOoz6qoRqvoLLQxLppH7ELWfiklcjAcLk7D6yZ5Fl1jQEYjvU4s7J/26eVs5FTBWw== X-Received: by 2002:a0d:eacb:0:b0:618:8d66:8363 with SMTP id 00721157ae682-622afff94c0mr320651257b3.41.1716068749577; Sat, 18 May 2024 14:45:49 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6209e379631sm44248927b3.124.2024.05.18.14.45.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 May 2024 14:45:49 -0700 (PDT) Date: Sat, 18 May 2024 14:45:46 -0700 From: Noah Misch To: Masahiko Sawada Cc: Joe Conway , Peter Eisentraut , Tom Lane , Alexander Korotkov , "Guo, Adam" , "pgsql-hackers@lists.postgresql.org" , Nathan Bossart , Jim Mlodgenski Subject: Re: pg_trgm comparison bug on cross-architecture replication due to different char implementation Message-ID: <20240518214546.e8@rfd.leadboat.com> References: <3335675.1713884256@sss.pgh.pa.us> <1685377.1714496091@sss.pgh.pa.us> <1696557.1714498172@sss.pgh.pa.us> <2652929.1714745623@sss.pgh.pa.us> <3846ef0f-5273-41aa-a77e-f92841e0515f@eisentraut.org> <362570f3-1031-4f8e-a077-81c103200b64@joeconway.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/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, May 15, 2024 at 02:56:54PM +0900, Masahiko Sawada wrote: > On Sat, May 4, 2024 at 7:36 AM Joe Conway wrote: > > On 5/3/24 11:44, Peter Eisentraut wrote: > > > On 03.05.24 16:13, Tom Lane wrote: > > >> Peter Eisentraut writes: > > >>> On 30.04.24 19:29, Tom Lane wrote: > > >>>> Also, the bigger picture here is the seeming assumption that "if > > >>>> we change pg_trgm then it will be safe to replicate from x86 to > > >>>> arm". I don't believe that that's a good idea and I'm unwilling > > >>>> to promise that it will work, regardless of what we do about > > >>>> char signedness. That being the case, I don't want to invest a > > >>>> lot of effort in the signedness issue. Option (1) is clearly > > >>>> a small change with little if any risk of future breakage. > > >> > > >>> But note that option 1 would prevent some replication that is currently > > >>> working. > > >> > > >> The point of this thread though is that it's working only for small > > >> values of "work". People are rightfully unhappy if it seems to work > > >> and then later they get bitten by compatibility problems. > > >> > > >> Treating char signedness as a machine property in pg_control would > > >> signal that we don't intend to make it work, and would ensure that > > >> even the most minimal testing would find out that it doesn't work. > > >> > > >> If we do not do that, it seems to me we have to buy into making > > >> it work. That would mean dealing with the consequences of an > > >> incompatible change in pg_trgm indexes, and then going through > > >> the same dance again the next time(s) similar problems are found. > > > > > > Yes, that is understood. But anecdotally, replicating between x86-64 arm64 is > > > occasionally used for upgrades or migrations. In practice, this appears to have > > > mostly worked. If we now discover that it won't work with certain index > > > extension modules, it's usable for most users. Even if we say, you have to > > > reindex everything afterwards, it's probably still useful for these scenarios. Like you, I would not introduce a ControlFileData block for sign-of-char, given the signs of breakage in extension indexing only. That would lose much useful migration capability. I'm sympathetic to Tom's point, which I'll attempt to summarize as: a ControlFileData block is a promise we know how to keep, whereas we should expect further bug discoveries without it. At the same time, I put more weight on the apparently-wide span of functionality that works fine. (I wonder whether any static analyzer does or practically could detect char sign dependence with a decent false positive rate.) > +1 > > How about extending amcheck to support GIN and GIst indexes so that it > can detect potential data incompatibility due to changing 'char' to > 'unsigned char'? I think these new tests would be useful also for > users to check if they really need to reindex indexes due to such > changes. Also we fix pg_trgm so that it uses 'unsigned char' in PG18. > Users who upgraded to PG18 can run the new amcheck tests on the > primary as well as the standby. If I were standardizing pg_trgm on one or the other notion of "char", I would choose signed char, since I think it's still the majority. More broadly, I see these options to fix pg_trgm: 1. Change to signed char. Every arm64 system needs to scan pg_trgm indexes. 2. Change to unsigned char. Every x86 system needs to scan pg_trgm indexes. 3. Offer both, as an upgrade path. For example, pg_trgm could have separate operator classes gin_trgm_ops and gin_trgm_ops_unsigned. Running pg_upgrade on an unsigned-char system would automatically map v17 gin_trgm_ops to v18 gin_trgm_ops_unsigned. This avoids penalizing any architecture with upgrade-time scans. Independently, having amcheck for GIN and/or GiST would be great.