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 1sm5Da-0036tc-Ri for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Sep 2024 05:39:43 +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 1sm5DZ-003mSw-Cf for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Sep 2024 05:39:41 +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 1sm5DZ-003mSo-2h for pgsql-hackers@lists.postgresql.org; Thu, 05 Sep 2024 05:39:41 +0000 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sm5DW-000E5Q-RX for pgsql-hackers@postgresql.org; Thu, 05 Sep 2024 05:39:40 +0000 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-26ff21d82e4so239984fac.2 for ; Wed, 04 Sep 2024 22:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725514778; x=1726119578; 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=O647okAsUfowU+jSy+e7J53/8sS0tEgOwuKHOWDlGnU=; b=BTvCDpg0V4vJCYg/Y2ngLDWkIvzTgJXcXBu3nMyjlHT6QCjcD+4oX2qqIgnjnboMDt qxN5CSFvNB5oEmq9tLpgHoAxNU96HLU91mLJcgq0hLTY0rIHrEIFwji7et7Ia35LhdRt ejbdFnsBy9x3MvZnFHwtqhbdeAv0J0ETKZITq+k3hed9sGE0AkZyiAxiVjtA7cSKdBmq vXNTviOiBuDpy0XyeK3/b+Xd412uZAbZ9mHclJWhu1KlgmmPPyEv9tjcOW+5CO4TUEQC FcAuThov+RSPCBYiPS9kwSM7u30cYPmzbhjnaXAFOQPxCxYfmmznhb8k2A/+t5s2Y927 d7bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725514778; x=1726119578; 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=O647okAsUfowU+jSy+e7J53/8sS0tEgOwuKHOWDlGnU=; b=POnhPCEjUEKCOVrRYB64CaI3V3dXAWTqK1o/yQOceUdGLPlcmb7M1jC2Rh5yC98QxN E95nB1DDNJ99tVtiLB31mghGZOij2s6vxrwMglF/jtJMDEzVgEFubp92RvwLQBxBPThg Q+bL5AZORI1dfTQRRxacdyzEon4W7WOJ4GHfdlhr0PvEMhvddsR+vNLJ9QoJ8camwYQ3 YwDdyyEGjATNRf7eMHvf110z474cydG/4sjDl1WDaq0zIP2KWAo91vNXI+zwp9YyBOhd eZDhN9TTH0mdRc5hsY1g7R4ZQn2toxfM1enN+HWtjVDlEharoAyaIeYDMcOzf2BgOS37 Ud0g== X-Gm-Message-State: AOJu0YymVxcwZqvw4abC+Q2rumSfTwi/JILln5I8u4SbkV1B+goET56F HUjdvr0+7sD9ZpnxiF6bc8rMrX10CyjabzESFIeC8ffjBUeV8zTwyjLhdEhNcMDLOYoY05Hi17s V2GcY7sAlwr0SkPCmn9Tw4KuhvWk= X-Google-Smtp-Source: AGHT+IELGu5jd6Pp4QFAAWpwyCQ14gQGsafy5V4GJECnSOJnQaYa4mzyyzyelNxJQEQcLmwV8zLrmZMW6GH3fQUiyGE= X-Received: by 2002:a05:6870:44cf:b0:278:157:25bb with SMTP id 586e51a60fabf-27801572e92mr11662462fac.26.1725514777843; Wed, 04 Sep 2024 22:39:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Thu, 5 Sep 2024 11:09:26 +0530 Message-ID: Subject: Re: Commit Timestamp and LSN Inversion issue To: Aleksander Alekseev Cc: pgsql-hackers , shveta malik , "Zhijie Hou (Fujitsu)" , tomas@vondra.me 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 Wed, Sep 4, 2024 at 6:35=E2=80=AFPM Aleksander Alekseev wrote: > > > > I don't think you can rely on a system clock for conflict resolution. > > > In a corner case a DBA can move the clock forward or backward between > > > recordings of Ts1 and Ts2. On top of that there is no guarantee that > > > 2+ servers have synchronised clocks. It seems to me that what you are > > > proposing will just hide the problem instead of solving it in the > > > general case. > > > > > > > It is possible that we can't rely on the system clock for conflict > > resolution but that is not the specific point of this thread. As > > mentioned in the subject of this thread, the problem is "Commit > > Timestamp and LSN Inversion issue". The LSN value and timestamp for a > > commit are not generated atomically, so two different transactions can > > have them in different order. > > Hm.... Then I'm having difficulties understanding why this is a > problem This is a potential problem pointed out during discussion of CDR [1] (Please read the point starting from "How is this going to deal .." and response by Shveta). The point of this thread is that though it appears to be a problem but practically there is no scenario where it can impact even when we implement "last_write_wins" startegy as explained in the initial email. If you or someone sees a problem due to LSN<->timestamp inversion then we need to explore the solution for it. > > and why it was necessary to mention CDR in this context in the > first place. > > OK, let's forget about CDR completely. Who is affected by the current > behavior and why would it be beneficial changing it? > We can't forget CDR completely as this could only be a potential problem in that context. Right now, we don't have any built-in resolution strategies, so this can't impact but if this is a problem then we need to have a solution for it before considering a solution like "last_write_wins" strategy. Now, instead of discussing LSN<->timestamp inversion issue, you started to discuss "last_write_wins" strategy itself which we have discussed to some extent in the thread [2]. BTW, we are planning to start a separate thread as well just to discuss the clock skew problem w.r.t resolution strategies like "last_write_wins" strategy. So, we can discuss clock skew in that thread and keep the focus of this thread LSN<->timestamp inversion problem. [1] - https://www.postgresql.org/message-id/CAJpy0uBWBEveM8LO2b7wNZ47raZ9tV= Jw3D2_WXd8-b6LSqP6HA%40mail.gmail.com [2] - https://www.postgresql.org/message-id/CAJpy0uD0-DpYVMtsxK5R%3DzszXauZ= BayQMAYET9sWr_w0CNWXxQ%40mail.gmail.com --=20 With Regards, Amit Kapila.