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 1tBaF7-004nFF-OJ for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Nov 2024 13:50:41 +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 1tBaF5-003gkp-3y for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Nov 2024 13:50:39 +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 1tBaF4-003gkh-La for pgsql-hackers@lists.postgresql.org; Thu, 14 Nov 2024 13:50:39 +0000 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tBaF2-001qAN-61 for pgsql-hackers@postgresql.org; Thu, 14 Nov 2024 13:50:37 +0000 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3e600ae1664so267791b6e.2 for ; Thu, 14 Nov 2024 05:50:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wi3ck-info.20230601.gappssmtp.com; s=20230601; t=1731592235; x=1732197035; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=TVggTCFIPNfdqRMoPqrPZzn638a0sO98VCKKCqMP1Zk=; b=zSTf5ADZCZEDkBIsjzykBHEfSehhYpO3/uqRGyiX9pLlZJ+8B/4RytlPc789m1gL97 vl3d6VD1Uc/Ldk1rEB26xl46eJqzhhe2NQrS9AtfoLoo/KtiLgEnWkM2iJAg4CjC+h07 Ja3a8vI/rSZzBOClmVZ2SUg9Dv6AeKj/fJo4JCAHNyKSgixGL7SAwQqdWZh+cqhU5Gzh 2xJqU80ZYqMCeOOw1kX3+juYvanZs5p6uWzxjlQe0y1cS9mrz4w/KPiHNTUAoLekwYM/ WkYnn/jqbwqvtL3y5I6QS/xZi2bD4IBKZQ3Klr/d8jgHMGQ7PO3uxKGqz1BI87WBMZG0 GlPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731592235; x=1732197035; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TVggTCFIPNfdqRMoPqrPZzn638a0sO98VCKKCqMP1Zk=; b=BhQD+ceK7kNiAHjw1EUT2JDafxeonbQ5D3hgkjoLkVXI5F/hL2ymmlp1u4y5/PVMoe m8O/kdciN7GdqWHS8VHlu9Nydx8bRGzIK0/pxgCVk768b9e3jwNx7+TIoHI/AIA1Ahd+ YnLjC0hIYWeHLpymab1HovDtZywppeeybvvoWCgxEfluJlfLojYSrm1q4TfOoA8g690D Rj31cAfgULVXeWVzhI+6Je7/IJE3rZ82I+6BOrdQJD7IkJFR3RHfstubaessssrg0Us+ pUkQwWmsqfp4fUO28Vwj5bF44ESdRU1Pi1T5Ppe6hEmspCusUePDJp4IkOlXaLPpoviV u7jw== X-Forwarded-Encrypted: i=1; AJvYcCXbCJmLXp7bzEVlj5gJbL7bhxsPvB3uzjJkeCopVAhM8a/UsJFYBlf9JdPYa3z9nUNYKQu2I9YAThN2II8I@postgresql.org X-Gm-Message-State: AOJu0YxxEAd04OKFLUAi74dXfrN8Idc+LDqRNzLZZGwXfENk8RisIm+5 EBIPzvZRXnG3z0ZD8MbF47SMF3mFeNmDzcGvBIK56MXu9+VraJ+ZeIKh5+sdA9s= X-Google-Smtp-Source: AGHT+IFO66yLHNSSaCsdCrcyfRKarkfEO5P8BlFWH7z1G1xsnx67iFEhoYsu3C1mf0jzVO9mT57i2A== X-Received: by 2002:a05:6808:bc2:b0:3e6:2e8d:9147 with SMTP id 5614622812f47-3e79457e15bmr22441828b6e.0.1731592233774; Thu, 14 Nov 2024 05:50:33 -0800 (PST) Received: from [172.21.0.10] (pool-108-16-53-81.phlapa.fios.verizon.net. [108.16.53.81]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d3f81832easm1245006d6.59.2024.11.14.05.50.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Nov 2024 05:50:33 -0800 (PST) Message-ID: <00888abf-dbda-4a58-8af1-8de6a54f1f4e@wi3ck.info> Date: Thu, 14 Nov 2024 08:50:31 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Commit Timestamp and LSN Inversion issue To: Amit Kapila , Tomas Vondra Cc: Andres Freund , "Zhijie Hou (Fujitsu)" , Aleksander Alekseev , pgsql-hackers , shveta malik , Jan Wieck References: <9f7f4def-7ea8-4ad3-83e7-a8cc9d18c58a@wi3ck.info> <11ee3489-40ba-45d6-ba6a-7c3def725e84@vondra.me> <2c754a6c-478f-4a9e-9f3f-4ea6d8db5188@vondra.me> Content-Language: en-US From: Jan Wieck In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/13/24 03:56, Amit Kapila wrote: > the key point Andres > is raising is that we won't be able to convert the operation in > ReserveXLogInsertLocation() to use atomics after such a solution. Now, > even, if the change is only in the *commit* code path, we may or may > not be able to maintain two code paths for reserving LSN, one using > atomics and the other (for commit record) using spinlock. Which is only partially true. There is nothing that would prevent us from using atomic operations inside of a spinlock and only reserving xlog space for commit records needs a spinlock because of the extra logic that cannot be combined into a single atomic operation. The idea as I understand Andres is that changing ReserveXLogInsertLocation() to use atomics gets rid not only of the spinlock, but also the LW-locks that protect it from a spinlock storm. Keeping the current LW-lock plus spinlock architecture only for commit records but changing the actual reserve to atomic operations would affect small transactions more than large ones. Making all of this depend on "wal_level = logical" removes the argument that the two solutions are mutually exclusive. It does however make the code less maintenance friendly. Best Regards, Jan