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.96) (envelope-from ) id 1wDfKt-003Dll-0S for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Apr 2026 09:18:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wDfKr-009HMO-0o for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Apr 2026 09:18:01 +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.96) (envelope-from ) id 1wDfKq-009HMF-34 for pgsql-hackers@lists.postgresql.org; Fri, 17 Apr 2026 09:18:00 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wDfKo-00000001dEt-2Sav for pgsql-hackers@lists.postgresql.org; Fri, 17 Apr 2026 09:18:00 +0000 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-c76d797b180so365642a12.2 for ; Fri, 17 Apr 2026 02:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776417476; x=1777022276; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5BUS76i1ofMfqaVM050tAjXGAaadtEBUaDGSOh/iS3g=; b=VGIfMl6KePC7w1CbrIb7UTVTOlgWDbxNSSCTJD+gQ4FWeKw3P1RMPuTvinzQY2T2ue vL6npvM1VASeasMECatsDmTUj3/2MRsN8Q36dvAyQxFpdqfJSAWKKIphrEdC+E0vE8Vf vbSIyYUINwhqRvg/rK2uyJif58YJpZy9CgYVBL05GyrR0cfwbrkdgPTvi3PIXJSoCndX +FtUH3k5753VaJYdgd20jM/dJdfgsl9DrtgdfI4tYiHqVPw82GR7uvguFWUJcQ3zgTTs N/+2H4vHQXH35waM0T7P+3k6QWAtyqpaYlJT/vd+ZjPlPI7mWNM3DVG0RsL0F9EXA+5B Pkbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776417476; x=1777022276; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5BUS76i1ofMfqaVM050tAjXGAaadtEBUaDGSOh/iS3g=; b=CV37co5OgHXw2pM1D6ChHCGl+4uckdibbraRFy1F7leDW5GbmnzYCFKgH2Z5/NpZdq a9XRjJYUJSEr06bJwaviIyaSkdNKakm8zwxV9QRiJESuZ7DNStH+DGlbuNmJIlZwxE5b Imm3rLnHsiGrVVtCuRA+tzWaTORUOQ251hJG3lkNo7kg/Sl1c6qrObkn5qF7Ycb0E7CB rmGAoJ8kbgEA4l7MyaP+Q7KV3Z4CFsmYuWD6BgNLD5qdQtXNc4bVCIUqUsQV3imw+xwc ccTlNwarHql04qs3nyOQCVwSYgwqtMb33IlYgRJV888HpDkvv/WRHgWsxdWZvVZLbrhm dZCw== X-Gm-Message-State: AOJu0YzXChJCndyVYsuL88IhIkanDHfQcA3AskhErY8giqO+Ottj7rdV bxnOkpgcjCZk6WVODD6/5WhEKfmv0Sw1cBALIsk6bFT6mu111MZKa9XE X-Gm-Gg: AeBDiet8Huvt0x21DgJkNg12DAyXjTdJwel2nbbw68aAoyp+hQsZ7jGTcBRu+p7AcpD bw12oost1UNz514C4r7CLvt4RxnURjIaO4kqoyiBiQlfR3NYtCsu1CfExXGMLMJIeVTmqPLkk2T 5DXqzoWKdFekmJYH8uosRLICF+mRE6IlhHt6r7i3/V8VDB+WrMFu7etPt92VnpZPM6Vlp2tnPbn lIXNS92hfUNZQ+i9ipeHCyh2r3KcwH0T4Wr5Em7vSew8k1Voxu/MQsA3tx5sJ69KN0BszIwyiNV j0l5C5jiWzZ4Q7Xq12ny+uNt6wcjQfV9Imb8L+cN1+FMnQMNJRtwtbXJ+uayU11jLmdcaOppGoV t72n9OGQ0lIT9PHqMJUkw/wJKQkwOXBOYbDmH1f+UOKaQIdYkL+Ok6tl86kYy1JlAHW6e8DAHAi CctpJRWZGptaruzTrTrdTjM/ct/yoDtcmlaUspg0wOCw== X-Received: by 2002:a05:6300:6404:b0:39b:c0b5:b0ee with SMTP id adf61e73a8af0-3a08d7266fcmr1563536637.12.1776417476040; Fri, 17 Apr 2026 02:17:56 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c797701d9bfsm1023432a12.16.2026.04.17.02.17.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Apr 2026 02:17:55 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: [PATCH] Compressed TOAST data corruption with REPACK CONCURRENTLY From: Chao Li In-Reply-To: Date: Fri, 17 Apr 2026 17:17:15 +0800 Cc: PostgreSQL Hackers , =?utf-8?Q?=C3=81lvaro_Herrera?= , ah@cybertec.at Content-Transfer-Encoding: quoted-printable Message-Id: <98247BB5-5FE5-4F32-A23D-0A3ED808AB19@gmail.com> References: To: SATYANARAYANA NARLAPURAM X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Apr 16, 2026, at 14:13, SATYANARAYANA NARLAPURAM = wrote: >=20 > Hi hackers, >=20 > restore_tuple() in repack.c uses SET_VARSIZE() to reconstruct the = varlena header when=20 > reading back external attributes from the spill file. In this process, = looks like the flag=20 > SET_VARSIZE_COMPRESSED is silently lost. Because of this, when REPACK = CONCURRENTLY > run any concurrently updated column whose value was TOAST-compressed = ends up with raw=20 > compressed bytes behind an "uncompressed" header returning garbled = data on subsequent reads. > It appears that existing tests are using random chars which are = uncompressable. >=20 > Please find the attached = 0001-Fix-restore_tuple-losing-varlena-compression-flag.patch to fix = this.=20 > Additionally I updated the existing repack_toast test to include the = scenario I was talking about. >=20 > Thanks, > Satya > = <0001-Fix-restore_tuple-losing-varlena-compression-flag.patch><0002-Add-co= mpressed-TOAST-test-to-repack_toast.patch> I managed to reproduce the bug manually, and confirmed your fix to work = for me. The repro is not simple, so I won=E2=80=99t put it here. If = somebody is interested in it, then I can provide. I didn=E2=80=99t review the test in 0002, I guess we don=E2=80=99t have = to add the test because once fixed, the bug won=E2=80=99t be there = anymore, thus it=E2=80=99s not worthy extending the test time. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/