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.94.2) (envelope-from ) id 1sapDL-00BOMU-T3 for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Aug 2024 04:20:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sapDK-00BCOc-AZ for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Aug 2024 04:20:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sapDK-00BCOU-0f for pgsql-hackers@lists.postgresql.org; Mon, 05 Aug 2024 04:20:54 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sapDH-0037LZ-Al for pgsql-hackers@postgresql.org; Mon, 05 Aug 2024 04:20:52 +0000 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-7092ea69218so2733687a34.1 for ; Sun, 04 Aug 2024 21:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722831651; x=1723436451; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GauizGGIKS79l2w/fcZnkZ1O3UaR1Yf3gjWt5B+xHOk=; b=eoWbwp+ajuhNp1zv0RNl3Z+80T3Q0BR/GNWLNhVTLSCGQS9tPzLLH++wd31oSmFWgn byQYhl0SyRvxgzmLL6nVZI3pI9RX+K0R3RRSmjkzbDlaDcuGGqeU5hzLh7HtP92KSmlm ZYmrwP2pvbtHIT7J9tbc4Mzl/poUef2PYO6X1ZDmSN8gNNBfe4qg00ewwjIYFdwyVZ/q WGZ0frFCLLtpPG64X0iW38wNmRndE6TqcwGN5Q1fbDk6p/uds8MmLstmAAggzp0sQ7pa U7wp2Jx+vyBNzuscmqIsKJ42Lh6xlwVAXc3h0RmxUY9ekaNz9b0Mue9UGwpm25alB1OZ WePw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722831651; x=1723436451; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GauizGGIKS79l2w/fcZnkZ1O3UaR1Yf3gjWt5B+xHOk=; b=tOpOYmNC3/OhbS2QwENk8oye1J5aPsArDCMIWn7D43MCZieD+qqVYYRB/J1PeliLj6 0OrUYYsxyhLvlb0YfKzcJ23dlh0aWoyT/uPaRPOgZP12qJmw9z2Atj4m74tfShrtCSdY CX3O5NbZ7ufTROZWJZlfudGIYZcYT6PLql+OqLqlVBxZOELNrqh3ZgS8uU3QdPhdR25p 9fz+mf9PfkJTQ92R1MPq40mJ0lKkKGcTuyNT03LQZucEcTWVuvDGeNHZjxOL3mPRZE2v PqObFprKLPbiwz6KV2YKwNl1JtP1SxkmOoXQyOnZAuKq4mr8wVrreYt9G8YTl/1ibOMK b+PA== X-Forwarded-Encrypted: i=1; AJvYcCUxQn+qB5JhQHMyE1Cv4W2ZWNmg0vNY+qDxS0kbmgi5vKiEG2n6WfAE/br4vw7tO+6MEkUtZxm2VaD+EqQIG5tpli2+oulcqJgD2E96 X-Gm-Message-State: AOJu0YzzhoqkrQ9ZyEFnb+HaOy1Ion9h57w7gMOGJvXh/TsvvUBj9rXJ kK2E9TtOkCvvqxnHO/H9PVSm/UfJeJWffj4gwWhYDBS/S+bhZ7pKLxgBnPtpMxul5+y0RklLVYs UAwel5yuPPA+oC4Eyn1Uhr3aP+CcKP4fD X-Google-Smtp-Source: AGHT+IEhRyn9xnVuHctwVHTHYabWJpb995mDbWo6FZl4VF7SRY2jKrQnunWZ1CiMLtSDWsjwstvMiXuh8JzCi7TOSyA= X-Received: by 2002:a05:6870:b91b:b0:265:b32b:c465 with SMTP id 586e51a60fabf-268877a4c75mr5304397fac.9.1722831650613; Sun, 04 Aug 2024 21:20:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Mon, 5 Aug 2024 09:50:38 +0530 Message-ID: Subject: Re: Conflict detection and logging in logical replication To: "Zhijie Hou (Fujitsu)" Cc: shveta malik , Nisha Moond , pgsql-hackers , Dilip Kumar , Jan Wieck , Tomas Vondra , Ashutosh Bapat Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Aug 4, 2024 at 1:04=E2=80=AFPM Zhijie Hou (Fujitsu) wrote: > > On Friday, July 26, 2024 2:26 PM Amit Kapila wr= ote: > > > > > > I agree that displaying pk where applicable should be okay as we displa= y it at > > other places but the same won't be possible when we do sequence scan to > > fetch the required tuple. So, the message will be different in that cas= e, right? > > After some research, I think we can report the key values in DETAIL if th= e > apply worker uses any unique indexes to find the tuple to update/delete. > Otherwise, we can try to output all column values in DETAIL if the curren= t user > of apply worker has SELECT access to these columns. > I don't see any problem with displaying the column values in the LOG message when the user can access it. Also, we do the same in other places to further strengthen this idea. > This is consistent with what we do when reporting table constraint violat= ion > (e.g. when violating a check constraint, it could output all the column v= alue > if the current has access to all the column): > > - First, use super user to create a table. > CREATE TABLE t1 (c1 int, c2 int, c3 int check (c3 < 5)); > > - 1) using super user to insert a row that violates the constraint. We sh= ould > see all the column value. > > INSERT INTO t1(c3) VALUES (6); > ERROR: new row for relation "t1" violates check constraint "t1_c= 3_check" > DETAIL: Failing row contains (null, null, 6). > > - 2) use a user without access to all the columns. We can only see the in= serted column and > CREATE USER regress_priv_user2; > GRANT INSERT (c1, c2, c3) ON t1 TO regress_priv_user2; > > SET SESSION AUTHORIZATION regress_priv_user2; > INSERT INTO t1 (c3) VALUES (6); > > ERROR: new row for relation "t1" violates check constraint "t1_c= 3_check" > DETAIL: Failing row contains (c3) =3D (6). > > To achieve this, I think we can expose the ExecBuildSlotValueDescription > function and use it in conflict reporting. What do you think ? > Agreed. We should also consider displaying both the local and remote rows in case of update/delete_differ conflicts. Do, we have any case during conflict reporting where we won't have access to any of the columns? If so, we need to see what to display in such a case. --=20 With Regards, Amit Kapila.