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 1ulW3p-0020YL-Lu for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Aug 2025 17:11:49 +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 1ulW3o-002Zx8-5T for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Aug 2025 17:11:48 +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 1ulW3n-002Zwb-Qr for pgsql-hackers@lists.postgresql.org; Mon, 11 Aug 2025 17:11:48 +0000 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ulW3l-0003Lx-1u for pgsql-hackers@lists.postgresql.org; Mon, 11 Aug 2025 17:11:47 +0000 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-61990d3392cso2351446eaf.1 for ; Mon, 11 Aug 2025 10:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mixrank.com; s=googledamrudlacagu; t=1754932305; x=1755537105; darn=lists.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=dcs5wlqffKlcSy3WAEuEa6bfUgo8pSY0bTuozz/le+c=; b=eWwuIC+DCUm56p6DvaHpbZCyvtg2RikysmoMplG6+OTi8ivtZgDpAQn5gN8jSzJhO5 4l06YOeRhytDRKYcEKvmQ72F11gdHTwnxHcy05cbV5S+9nvvShkyJHOxuzFJBw5AQOtD s64Uc+IBLMobzExhfJ0teneBKRcj07kqWQBzwcO8ODInUNiymcfmBbW5jM3XrCTLGHk9 nR18j4PrGs3FwNCDzh+qR4M8pQ1RR2vzKLvKWL6CiX0pLa2yKTYg8eEqJ4fS6UsywAi7 UqSUPL+E9j+SKLdJL10LVvPUqzmpYzntEraMIgHjFrsyuol0oToSlbgPs1Xw2UTpkdy6 6RRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754932305; x=1755537105; 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=dcs5wlqffKlcSy3WAEuEa6bfUgo8pSY0bTuozz/le+c=; b=Fxo+KlnD8d+wSPuOrcEInMmYK9hw6AauI674wRY5Rm+H3WPt2ufj2Oz9wtcXXyqe69 RZQ6hsETG0/6jEN2GKXy2LtQz8VAxi+9F5hBHwdETHF+m+rmz90gqdY17LoFifH9/do7 zUzDHTc2/t3DGCJtqtvsbcVhApaHZzB2ljoEJ2cURM5vaXEWnq9iXyJjaEUhVab35D7L 7yBJWjY63CG8NMQ4ZtmBVoYX0dXCWom4KS/nKajVOgG2dGW0ZhlvAjU2jQ+pc+ixJ1F5 LXHOjYJgVXo8bD+FgAXd3yw5QRJv42dvjpqDDd0ceulWtr00v2DjovBEAIYNnwDNMiLY gz9A== X-Gm-Message-State: AOJu0YyZpdOKeKOoqn2QCXi20tHu1/NAkaWK/w4vV06GVOw9RQGakIrX kelRyP9cg/9CwAcjKjzr9+RZPzcCM4xnpVWGU8TC71L9DXDNZc0kV4OKiyVONh8QgPUiXs2gDX5 nahRJQIRJjXXjaTztukTB1EykEh9/uTkC3MWtd2ptcA== X-Gm-Gg: ASbGncsMiiKBQXAxy2bshPFU4Ef2cbpQK8O4sUF4TpF/wzrVJtSeiTXN14udQ+967kG RKbzirGbnwm8U0ej9g/O3jDEhBAn7p1B+bvDzzCPTMqRuuAnXUAM6f5TTXzhXtBMXFUSmPO4znm W/lpFwSneIK4kWZtnSEVB8EzoX/q7z0ttQJR8YZ5b/vYVnq1X/vzNnsgmZRoNMtfURGAV9x/t3n 7DeNz2F X-Google-Smtp-Source: AGHT+IGrNu7OYByVvKx6GWFNlmPHdKePz967Y/pxl6xpc63TGBmqz16vAvDtfuuSk96sYLZtUmOkhmDVi5VGvCrUBgI= X-Received: by 2002:a05:6820:1b87:b0:61b:9b83:31c9 with SMTP id 006d021491bc7-61b9b83340cmr3313199eaf.5.1754932305275; Mon, 11 Aug 2025 10:11:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Doruk Yilmaz Date: Mon, 11 Aug 2025 20:11:34 +0300 X-Gm-Features: Ac12FXzdbH5fPkTUAcTUL4rB-PG7Pe2KdtFZkl34UKL0oAU3szYYJgUrNxRFe8g Message-ID: Subject: Re: [Patch] add new parameter to pg_replication_origin_session_setup To: Amit Kapila Cc: pgsql-hackers@lists.postgresql.org 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 Mon, Aug 11, 2025 at 9:44=E2=80=AFAM Amit Kapila wrote: > How do you advance the origin? Did you use > pg_replication_origin_advanc= e()? If so, you should be aware that it > can be used for initial setup; see comment in that API code... No, we don't use pg_replication_origin_advance(). We use pg_replication_origin_xact_setup() instead as I mentioned before. Each worker does the following: 1. Sets up its own replication-origin session with pg_replication_origin_session_setup() (using the master process PID). 2. Applies changes inside transactions. 3. Right before commit, calls pg_replication_origin_xact_setup(lsn, commit_timestamp). 4. Commits only if everything succeeded, so the origin only advances on a real commit. That way, the origin LSN moves forward only when the transaction is actually committed. If something fails or the process crashes, the origin stays at the last successful commit, and on restart we replay from the correct spot. It's safer than advancing the origin without knowing the transaction made it to disk. So the issue you described is not relevant for our implementation.