Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dq32t-0007kQ-5k for pgsql-bugs@arkaria.postgresql.org; Thu, 07 Sep 2017 20:05:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dq32s-0005Mk-Om for pgsql-bugs@arkaria.postgresql.org; Thu, 07 Sep 2017 20:05:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dq32B-00044M-8C for pgsql-bugs@postgresql.org; Thu, 07 Sep 2017 20:04:19 +0000 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dq323-0007Rc-Ej for pgsql-bugs@postgresql.org; Thu, 07 Sep 2017 20:04:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1504814651; x=1536350651; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=gDm6MHRQUHVNicr1GN0wc2a2mvycGHWuXiYDQdT2u04=; b=oxHz8jGa2V1aWXKSq/QVdLq3+n94JkIzoMAErBXEoL3QZO71hrb1+0Md GAZ/cDrZBixAvFKyX49j/1ElpzDMYWlNTTcI37Foo+ITF0zqO/Pye8oVZ fQAav484DVlEod5rxXcQdwYbvxHurLs23fCslJc3MgNwqD81IilThz+dT s=; X-IronPort-AV: E=Sophos;i="5.42,360,1500940800"; d="scan'208";a="691266713" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-64004.pdx4.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Sep 2017 20:02:55 +0000 Received: from EX13MTAUWC001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-64004.pdx4.amazon.com (8.14.7/8.14.7) with ESMTP id v87K2ZDr009612 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Thu, 7 Sep 2017 20:02:36 GMT Received: from EX13D11UWC004.ant.amazon.com (10.43.162.101) by EX13MTAUWC001.ant.amazon.com (10.43.162.135) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Thu, 7 Sep 2017 20:02:35 +0000 Received: from EX13D04UWA001.ant.amazon.com (10.43.160.47) by EX13D11UWC004.ant.amazon.com (10.43.162.101) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Thu, 7 Sep 2017 20:02:35 +0000 Received: from EX13D04UWA001.ant.amazon.com ([10.43.160.47]) by EX13D04UWA001.ant.amazon.com ([10.43.160.47]) with mapi id 15.00.1104.000; Thu, 7 Sep 2017 20:02:35 +0000 From: "Wong, Yi Wen" To: Alvaro Herrera , Michael Paquier CC: Peter Geoghegan , "Wood, Dan" , "pgsql-bugs@postgresql.org" Subject: Re: Old row version in hot chain become visible after a freeze Thread-Topic: [BUGS] Old row version in hot chain become visible after a freeze Thread-Index: AQHTJ10zEH9T5bMCDUufad1KxDA7S6Kp0agK Date: Thu, 7 Sep 2017 20:02:34 +0000 Message-ID: <1504814554687.86636@amazon.com> References: ,<20170906221217.fnmoipi5zi5w3yrl@alvherre.pgsql> In-Reply-To: <20170906221217.fnmoipi5zi5w3yrl@alvherre.pgsql> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.43.161.32] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Precedence: Bulk List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org ________________________________________ From: pgsql-bugs-owner@postgresql.org on = behalf of Alvaro Herrera Sent: Wednesday, September 6, 2017 3:12 PM To: Michael Paquier Cc: Peter Geoghegan; Wood, Dan; pgsql-bugs@postgresql.org Subject: Re: [BUGS] Old row version in hot chain become visible after a fre= eze >Michael Paquier wrote: >> frame #4: 0x00000001098fba6b postgres`FreezeMultiXactId(multi=3D34, >> t_infomask=3D4930, cutoff_xid=3D897, cutoff_multi=3D30, >> flags=3D0x00007fff56372fae) + 1179 at heapam.c:6532 >> 6529 * Since the tuple wasn't marked HEAPTUPLE_DEAD b= y vacuum, the >> 6530 * update Xid cannot possibly be older than the x= id cutoff. >> 6531 */ >> -> 6532 Assert(!TransactionIdIsValid(update_xid) || >> 6533 !TransactionIdPrecedes(update_xid, cutoff_= xid)); >> 6534 >> 6535 /* >> (lldb) p update_xid >> (TransactionId) $0 =3D 896 >> (lldb) p cutoff_xid >> (TransactionId) $1 =3D 897 >So, looking at this closely, I think there is a bigger problem here: if >we use any of the proposed patches or approaches, we risk leaving an old >Xid in a tuple (because of skipping the heap_tuple_prepare_freeze on a >tuple which remains in the heap with live Xids), followed by later >truncating pg_multixact / pg_clog removing a segment that might be >critical to resolving this tuple status later on. >I think doing the tuple freezing dance for any tuple we don't remove >from the heap is critical, not optional. Maybe a later HOT pruning >would save you from actual disaster, but I think it'd be a bad idea to >rely on that. There is actually another case where HEAPTUPLE_DEAD tuples may be kept and = have prepare_freeze skipped on them entirely. lazy_record_dead_tuple may fail to record the heap for later pruning for lazy_vacuum_heap if there is already a sufficiently large number of dea= d tuples in the array: /* * The array shouldn't overflow under normal behavior, but perhaps it * could if we are given a really small maintenance_work_mem. In that * case, just forget the last few tuples (we'll get 'em next time). */ if (vacrelstats->num_dead_tuples < vacrelstats->max_dead_tuples) ... It looks like we don't even check if the lazy_record_dead_tuple operation a= ctually did any actual recording in the tupgone case... if (tupgone) { lazy_record_dead_tuple(vacrelstats, &(tuple.t_self)); HeapTupleHeaderAdvanceLatestRemovedXid(tuple.t_data, = &vacrelstats->latestRemovedXid); tups_vacuumed +=3D 1; has_dead_tuples =3D true; } It's probably unsafe for any operations calling TruncateXXX code to assume = that old Xids don't stick around after a vacuum in itself. Thanks, Yi Wen --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs