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 1l3Yj2-00049l-IY for pgsql-hackers@arkaria.postgresql.org; Sun, 24 Jan 2021 06:18: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 1l3Yj1-0001FK-2T for pgsql-hackers@arkaria.postgresql.org; Sun, 24 Jan 2021 06:18: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 1l3Yj0-0001FD-Nn for pgsql-hackers@lists.postgresql.org; Sun, 24 Jan 2021 06:18:14 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l3Yit-0004e2-D1 for pgsql-hackers@lists.postgresql.org; Sun, 24 Jan 2021 06:18:13 +0000 Received: by mail-pf1-x42c.google.com with SMTP id w18so6495749pfu.9 for ; Sat, 23 Jan 2021 22:18:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=SpkDlvnu5in3y1ylWZ1UJZEo1HRG5ssIlngIwosTC8U=; b=jGxSLLbj0YV1D2iuDnJXQwoIVr53U2FbHshUYSbAE0pvBHFwzE7BqLve5aVfnYJ05j widdzrAm6M3tPG/8Sqm5X2G7LAD6TATJcTN4DPO5y0svOiXU2TJxjfD7gcDWNizTOPdj GHJiMVsxYcQNfSuAAXCLeKGVY0CI7RFH1OEaNK2nMzDzZHHZj2+SVkM2YIPa/+upujpY aqaXZtW4s3UQifsXOPR+e0Smlb+2kUi23QyWLsiBOoBpnsqRcjvBDlbuwWRuX9gntxh2 jpm9PIPrHZOm68pYLceaOwxf74CTVQDPVYqk2aojimkg8KoNizoJIuDk+Lc9+Mi/QxQD nB3w== 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:subject:message-id:mime-version :content-disposition; bh=SpkDlvnu5in3y1ylWZ1UJZEo1HRG5ssIlngIwosTC8U=; b=A/NX0boo7fPk5uC93ZrH5PxC+bl1yjBFLtAfEANN0wCCqq374XiD30l7wYMursFffP BzjbRE09/RsBuRnNLZHKUxTqgRcxhGcmyTUD5XSGNp2of8XoNX3bftE/89BjuE+iFZyV nmd568sxH0IlViKS6YhXTq8IRZ3tfi14woDF2CgT6rTBm7tA6erKBss4tlrHm44a13P1 8wokjFuvvVfbQUSGUTFDGeNXaA7yqwe8eAWSUDgtxVdqCnB+dkfM7DNb+SlQiKd33J/I mZ2grqYyiJLbmUnnBFRAvN337sLqsPbBxu+RJwa1YZh1LIUzW1hU/Mw07V/Je7mD2sQB L5nw== X-Gm-Message-State: AOAM533eZYV+BTMAP0wnX0vQgxyk3SvtqNLpjDHKFFUNHMzfZT2CmcGx pga+PyBIcrs1m7WVzpYRq6q8yi4nJAnHZQ== X-Google-Smtp-Source: ABdhPJwXZmW0F+s3miu5eNHso7gTP+BSa18c0zMFioco9HiOxkxuEs5mRHfGoX9qUgZ9Jx+Z+gPKEw== X-Received: by 2002:aa7:80d8:0:b029:1ae:6ac5:5324 with SMTP id a24-20020aa780d80000b02901ae6ac55324mr12434713pfn.1.1611469085145; Sat, 23 Jan 2021 22:18:05 -0800 (PST) Received: from nol (111-241-122-214.dynamic-ip.hinet.net. [111.241.122.214]) by smtp.gmail.com with ESMTPSA id q2sm13182205pfg.190.2021.01.23.22.18.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 22:18:04 -0800 (PST) Date: Sun, 24 Jan 2021 14:17:58 +0800 From: Julien Rouhaud To: pgsql-hackers@lists.postgresql.org Subject: Faulty HEAP_XMAX_LOCK_ONLY & HEAP_KEYS_UPDATED hintbit combination Message-ID: <20210124061758.GA11756@nol> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ikeVEW9yuYc//A+q" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --ikeVEW9yuYc//A+q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, While working on pg14 compatibility for an extension relying on an apparently uncommon combination of FOR UPDATE and stored function calls, I hit some new Asserts introduced in 866e24d47db (Extend amcheck to check heap pages): + /* + * Do not allow tuples with invalid combinations of hint bits to be placed + * on a page. These combinations are detected as corruption by the + * contrib/amcheck logic, so if you disable one or both of these + * assertions, make corresponding changes there. + */ + Assert(!((tuple->t_data->t_infomask & HEAP_XMAX_LOCK_ONLY) && + (tuple->t_data->t_infomask2 & HEAP_KEYS_UPDATED))); I attach a simple self contained script to reproduce the problem, the last UPDATE triggering the Assert. I'm not really familiar with this part of the code, so it's not exactly clear to me if some logic is missing in compute_new_xmax_infomask() / heap_prepare_insert(), or if this should actually be an allowed combination of hint bit. --ikeVEW9yuYc//A+q Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="trigger_assert.sql" DROP TABLE IF EXISTS t1; CREATE TABLE t1(id integer, val text); INSERT INTO t1 SELECT i, 'val' FROM generate_series(1, 500) i; BEGIN; SAVEPOINT s1; SELECT 1 FROM t1 WHERE id = 123 FOR UPDATE; UPDATE t1 SET val = 'hoho' WHERE id = 123; release s1; savepoint s1; SELECT 1 FROM t1 WHERE id = 123 FOR UPDATE; UPDATE t1 SET val = 'hoho' WHERE id = 123; COMMIT; --ikeVEW9yuYc//A+q--