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 1ugp6L-007fN4-Ds for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jul 2025 18:31:02 +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 1ugp6K-003kPT-28 for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jul 2025 18:31:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ugp6J-003kMl-Ng for pgsql-hackers@lists.postgresql.org; Tue, 29 Jul 2025 18:31:00 +0000 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ugp6G-001Wxn-1a for pgsql-hackers@lists.postgresql.org; Tue, 29 Jul 2025 18:30:59 +0000 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-41cd87eff4dso61306b6e.2 for ; Tue, 29 Jul 2025 11:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mixrank.com; s=googledamrudlacagu; t=1753813855; x=1754418655; 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=a5Cbh/DhdE9rY/zPi3M7wOoQAKkgPkQZ8+GF380qOfs=; b=LblFxZ5Kc3FN64YtM9gX3qrMvfm8rR3a3nqVR0XzZdWZlMsBM9If9VZmJn+Whgg3H+ fWxy+goBY9cnCENtwzozCzMNzwbc9EWgNDxTaZlSETpzqF+6uGZdWiHfarXQGqkIOPJL V3ZPC2UsRMFJcz1IVw61q6u6bwglsoM6FG9D19MDsP68aoU9kB9V/A4A3elFVQ065Dm5 7gmEo99hIShPuqcq+6kmW2nFYGy/DpMdlg4GOjL9RcXOt+QQdlyPSB08b3D2apRmo97v 67QE9+rjVrCi7BtOwVp8HlRwDtLQ0MwLdDgm4XTCkcc+5zNxRMOLZ89DsJetA4p9Umvv pA8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753813855; x=1754418655; 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=a5Cbh/DhdE9rY/zPi3M7wOoQAKkgPkQZ8+GF380qOfs=; b=oGxDdn6qV/X9nVlxvgbNcJs0IyCmasUxKygSpobwk+oBFTH+PFzc2LDlsyDIxaQiIW vzOW/KOz7BuKGeenSc+UL2PQ+2hXmq6bo1E/KDPTPd2tEizCax1PttM4qO2Uz+szFAv6 ysNYhglmBagFz8S18N580LUtTkXZh/8n3zlGiuxqyNK1SMkS420afYzXp/vQtcS1Veiu bOhf+5yigsmCbCNpaoTI8vFPmI+Di/rDsg9T2g3AECHppNKUoTvZ8LxFRQejB3kAAPG1 Jljz22dojUGmTYFLWPv3In2Ui2jlYABtHUb1aPLxsanZp4oKoWkZQfhqR5+yTqoZTqvi 0bTQ== X-Forwarded-Encrypted: i=1; AJvYcCXU3Ds3HCiFoHcMZ5Df8k6nHk5v4jabTjQNcyqvrDdt+MnS7hTo5uA88OMqsOD5UU2Z+Rzb5RO3AiPsmw7T@lists.postgresql.org X-Gm-Message-State: AOJu0Ywwoy91JXNoKK0YbxPtn8ptLS8LbTIwDwW+Xs+tT+kfZrTXm/gp FyLbWBj7syevYwKDbch5OMXqz4iGW8LofNVTrcGmFB2rs/NIhNHcMClNpQxKn/Xi238SNdz0J06 AYSajiVZPfaDS3UTmMbxd0AjtgdMYYmvv43dvst+uOA== X-Gm-Gg: ASbGncs6igI82H5zpEN5kD+MOWl/O4TYNtaVp+5ik51scP9gf1goSTy4QzBgPVJe9hH JsJtw2HzVLnqXReXh0oVmRfmijXkQcBJy7SSl7EBekpxR4aCSSlt95cM5AEvSCQFhXCR70DaIQf ycWwu7H87drWbPNR7wOHI/mrXeGVApYL2BxK4u7w+43pxaDcQ2ngqVdcy83fHXOeQ/M7GdXnaUP Kr7w4Hk X-Google-Smtp-Source: AGHT+IHMtj1KdmLX4a+dsMLp9iBDTMFO3nUCHi1ClxHNotieTRH5ebX1ag4ofRDGzgcpc2VbGNCst6j9D2OlG1Gp718= X-Received: by 2002:a05:6808:4a4a:20b0:410:f243:a502 with SMTP id 5614622812f47-431993cac26mr367009b6e.8.1753813855309; Tue, 29 Jul 2025 11:30:55 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Doruk Yilmaz Date: Tue, 29 Jul 2025 21:30:43 +0300 X-Gm-Features: Ac12FXyr5yvggleofkOulTuWJE1Oa9rnU2AHt3Ggbk4FInumI8KdUpElbVW7VZg Message-ID: Subject: Re: [Patch] add new parameter to pg_replication_origin_session_setup To: Amit Kapila Cc: Euler Taveira , 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, Jul 29, 2025 at 8:13 AM Amit Kapila wrote= : > That is true but I still feel there has to be some mechanism where we > can catch and give an ERROR to the user, if it doesn't follow the > same. For example, pg_replication_origin_advance() always allows going > backwards in terms of LSN which means if one doesn't follow commit > order, it can lead to breaking the replication as after restart the > client can ask to start replication from some prior point. If you have any ideas for safeguards or API changes, I'd be happy to help implement them or discuss them. > Can you tell us the use case? Did you also intend to use it for parallel = apply, if so, can you also tell at a high > level, how you are planning to manage origin? Yes, we use it for parallel apply. We have a custom logical replication system that applies changes using multiple worker processes, each with their own database connection. Our use case requires multiple connections to be able to advance the same replication origin. We handle this by having a master process coordinate the workers, where each worker process calls pg_replication_origin_session_setup with the master's PID as the second parameter. We may send operations out of order but we always commit in order, so there's no chance of creating inconsistencies. There's the chance of deadlocks, but these can be detected. It's really similar to the existing parallel apply implementation - the main difference is that we're applying from jsonl files instead of directly from another database. Currently we use a local patch to expose the PID parameter, but having this upstream would be great. It causes a lot of headaches for us to use a patched PostgreSQL. Thanks, Doruk Y=C4=B1lmaz