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 1m5Xii-0007Xs-2C for pgsql-bugs@arkaria.postgresql.org; Mon, 19 Jul 2021 18:10:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m5Xih-0005JW-0e for pgsql-bugs@arkaria.postgresql.org; Mon, 19 Jul 2021 18:10:23 +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 1m5Xig-0005JO-J7 for pgsql-bugs@lists.postgresql.org; Mon, 19 Jul 2021 18:10:22 +0000 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m5Xia-00049t-8z for pgsql-bugs@lists.postgresql.org; Mon, 19 Jul 2021 18:10:21 +0000 Received: by mail-io1-xd2a.google.com with SMTP id z11so21108421iow.0 for ; Mon, 19 Jul 2021 11:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=jRuXzPj/DQwALN0Oj/MKeV6r58kt0MO37+H2kzWtAZs=; b=Hv/wxyYTovtAgKGk6uuWNv7/hPEwETR9rxgdL02jHqOLKP6PkVHFYXc8J6hRzzYjJf 1RluhrCwwQtQ5olELU+vMglWISHkfD/RxaybiNPaxeKASkpFiHH6wXpIIwdQiH+G8uzb fsR2FYPY8o2qOTJbGRXEh8O+xHfqMqyK9gNQs= 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:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=jRuXzPj/DQwALN0Oj/MKeV6r58kt0MO37+H2kzWtAZs=; b=OY55p8egW1eBqC1u/OSbppGiUBTx6WKliBUjwlEkPsu+Oniqv+mdWU/y9/cXh1tTmQ 718n/ChoyEsyK7unVkE/etMWZurhZT2SpWYcc7STL5FurzIg0wTlcz3j6nXkUEI2UKbD xcXIsmJOLppWFWTmaaXNpxp+ANnJvRaib5/kWnqXZD3qvcifkgfs+BiSajyW+zaxQ+ge uki2Qt1ICA7xrRxcpthSA4kII1AWSw5g/ynMgIN1vzKQsj82PF3yc0fXslqd4UHgbdmq rel+tJqu2UUmWGeaENyfKIuRTEgeh6wVyR7dk2CA4chzzTXr35/gJGcyUpzafR2XIQFm v0BA== X-Gm-Message-State: AOAM530IzL8t5x3ubLHM/OycyRxaUgwkfPM+u2bOzGl9Jg+xhj5NtJdz Lat49rT/ma3WlOIDkrYbQnkyTQ== X-Google-Smtp-Source: ABdhPJyGoB2R9dZgqkBHKYjDiLevT+wRzhZLcJT5wUtBvlc08JKQReZaEzmiJ33Qud2HmGN28fvBUQ== X-Received: by 2002:a5e:c645:: with SMTP id s5mr17688218ioo.193.1626718215521; Mon, 19 Jul 2021 11:10:15 -0700 (PDT) Received: from gust.leadboat.com ([172.243.183.102]) by smtp.gmail.com with ESMTPSA id i2sm10101347ilq.83.2021.07.19.11.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 11:10:14 -0700 (PDT) Date: Mon, 19 Jul 2021 14:10:05 -0400 From: Noah Misch To: Andrey Borodin Cc: Michael Paquier , Tom Lane , pgsql-bugs@lists.postgresql.org Subject: Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data Message-ID: <20210719181005.GB972361@gust.leadboat.com> References: <20210117072454.GA1709971@rfd.leadboat.com> <20210124022743.GA2270535@rfd.leadboat.com> <74C78048-70E8-4356-8F10-6370C37136C8@yandex-team.ru> <9C782C9D-D53E-4154-B910-46F062A9AE9B@yandex-team.ru> <01824242-AA92-4FE9-9BA7-AEBAFFEA3D0C@yandex-team.ru> <20210717201240.GA874334@gust.leadboat.com> <20210719003009.GA931573@gust.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jul 19, 2021 at 12:10:52PM +0500, Andrey Borodin wrote: > > 19 июля 2021 г., в 05:30, Noah Misch написал(а): > > > > To fix $SUBJECT, it sounds like we need a way to identify a transaction, > > usable as early as the transaction's first catalog access and remaining valid > > until COMMIT PREPARED finishes. We may initially see a transaction as having > > a VXID and no XID, then later need to wait for that transaction when it has > > entered prepared state, having an XID and no VXID. How might we achieve that? > > PFA draft with vxid->xid mapping and subsequent wait for it. The patch, obviously, lacks a ton of comments explaining what is going on. > We write actual VXID into dummy proc entries of prepared xact. > When we wait for vxid we try to convert it to xid through real proc entry. If we cannot do so - we lookup in shared 2pc state. If vxid is not there - it means it is already gone and there's nothing to wait. When the system reuses BackendId values, it reuses VXID values. In the general case, two prepared transactions could exist simultaneously with the same BackendId+LocalTransactionId. Hmm. It could be okay to have a small probability that CIC waits on more transactions than necessary. Suppose we have three PGPROC entries with the same VXID, two prepared transactions and one regular transaction. Waiting for all three could be tolerable, though avoiding that would be nice. Should we follow transactions differently to avoid that?