Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLxGn-0006Lz-BG for pgsql-general@arkaria.postgresql.org; Thu, 24 May 2018 20:55:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fLxGl-0002u1-UA for pgsql-general@arkaria.postgresql.org; Thu, 24 May 2018 20:55:31 +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.89) (envelope-from ) id 1fLxCZ-0002U7-C1 for pgsql-general@lists.postgresql.org; Thu, 24 May 2018 20:51:11 +0000 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fLxCS-0008UR-6O for pgsql-general@postgresql.org; Thu, 24 May 2018 20:51:10 +0000 Received: by mail-qk0-x241.google.com with SMTP id j80-v6so717957qke.9 for ; Thu, 24 May 2018 13:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=1Hm5YGp98LifpRwrgYhnqpvlWGOfLYZZpofsjPbIZKM=; b=igAyxBkpY+KhfOfHam8gTA4A0sLdVIp+IErt1DPrgysvGLwxLKHTcLr0ru6wwpyBYx FoJgt1VQwE9pd2sLFt5ZLa8fgsdItrvhLfO/9cYg3UuqsT74pIOxFpPYklws0BuUkQSE TjQvb+DVmmJ2c9OBRDyLtG1XKdq9jxY6pqqfiCdKm1VBRLRH6XDqCKbFYRvInyEJuzY4 ufwBmGWQbNBdVBaY7cWjwUNEmcVu/YMD0MLUxhW/5I7bMORuXZwG0ELcGfpcuZnIuJmR YvVOwfqFLNd9MbVz5dx7pkeLGHselgKWgMZ8olejICPqgyIFX3mG4L7nIK07rQWUvRfD d82A== 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:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=1Hm5YGp98LifpRwrgYhnqpvlWGOfLYZZpofsjPbIZKM=; b=AMimM84t08CI4/8zpwQNUdmIl7+BvP2rGpOsySHb4Z0EVYcPdOoPqUFTCuQFS3rAmy tWhnKtoXWjT1nuU/drORDDfL//pfXp6bMAb7eGN9vRF3K+YqYISp9HentmQSQuCmkHpX 67dSN2wp497HpyiN2A/kx0d3MwWWtoMbsb7a00Shg489E03VUF2Rcrgu8BhbSWUwvNRn yqF0MSXEFp7fwKZye6vRAuHhi6yVEypXnwrDJ1UhX+85EPkllnBSotHgNEn8vSZXtCna Fiv46gvZAB747kaeOwFvi36Xspb0080LlAtTQE6R+J/idbRdYIA42W7CPE0bk7sbyzCR h2Ag== X-Gm-Message-State: ALKqPwd7lzHKeTX2+XrMW8z4We3T2QM7nqxFC5s+f/IWE6U18AQZKkki MiOxUH8ZexckSXfOWJhy7YdNxw== X-Google-Smtp-Source: ADUXVKLPZdh50znEupoL5ABw0Qxyak7PQ+8I2erBCkoBEXM/0pU+nNd4SKkLSI3yR9VXEqr5KTYKCA== X-Received: by 2002:a37:c3d9:: with SMTP id r86-v6mr8224022qkl.267.1527195062362; Thu, 24 May 2018 13:51:02 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([179.57.112.31]) by smtp.gmail.com with ESMTPSA id b13-v6sm15720294qtp.89.2018.05.24.13.51.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 May 2018 13:51:01 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id BF78D74E; Thu, 24 May 2018 16:46:24 -0400 (-04) Date: Thu, 24 May 2018 16:46:24 -0400 From: Alvaro Herrera To: Andres Freund Cc: Maxim Boguk , Peter Geoghegan , Jeremy Finzel , Postgres General Subject: Re: found xmin from before relfrozenxid on pg_catalog.pg_authid Message-ID: <20180524204624.7ayv3bi3gsyagmsh@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180524203054.k7lnxjbe2unfvsgm@alap3.anarazel.de> User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-May-24, Andres Freund wrote: > On 2018-05-24 13:08:53 -0400, Alvaro Herrera wrote: > > Hmm .. surely > > xid = HeapTupleHeaderGetXmin(tuple); > > xmin_frozen = ((xid == FrozenTransactionId) || > > HeapTupleHeaderXminFrozen(tuple)); > > - if (TransactionIdIsNormal(xid)) > > + if (!xmin_frozen && TransactionIdIsNormal(xid)) > I don't think that's necesary - HeapTupleHeaderGetXmin() returns > FrozenTransactionId if the tuple is frozen (note the > HeapTupleHeaderXminFrozen() within). Ah, yeah ... I probably thought about this when writing it and removed it for that reason. BTW I think the definition of HeapTupleHeaderXminFrozen is seriously confusing, by failing to return true if the xmin is numerically FrozenXid (which it'll be if the database was pg_upgraded). I wonder about this one in HeapTupleSatisfiesMVCC: else { /* xmin is committed, but maybe not according to our snapshot */ if (!HeapTupleHeaderXminFrozen(tuple) && XidInMVCCSnapshot(HeapTupleHeaderGetRawXmin(tuple), snapshot)) return false; /* treat as still in progress */ } I think this is not a bug only because XidInMVCCSnapshot does this /* Any xid < xmin is not in-progress */ if (TransactionIdPrecedes(xid, snapshot->xmin)) return false; which makes it return false for FrozenXid, but seems more of an accident than explicitly designed. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services