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 1u4P2j-001cIE-P4 for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Apr 2025 19:00:30 +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 1u4P2g-004CkP-Uj for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Apr 2025 19:00:27 +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 1u4P2g-004CkE-Ji for pgsql-hackers@lists.postgresql.org; Mon, 14 Apr 2025 19:00:27 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u4P2e-00051t-0F for pgsql-hackers@lists.postgresql.org; Mon, 14 Apr 2025 19:00:27 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-54996d30bfbso4187217e87.2 for ; Mon, 14 Apr 2025 12:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744657224; x=1745262024; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=BM9zwBpaPC50zA2czQ1RcEEwRBmd8ElcrZUeF7ivEoo=; b=lQ+Z1XKKwWDTupsAsM0OjK9iZIy/58IQUBLJh7X9S5VfHvmtjqt6xslDlRgbtCrq0f s25V5uTHxMcxzF0msIuAXA6BTyRmhbpuz0eWCJbFGXRBmQUe3KXAGV0Ov/qcMFHUCZuT 4iCq7ZRJdcmorORwZtShy0MdceYwqP78nq3oNZw83u0IyfLIdJJHGRmqEN7IhmhL4SJC c9wk3Gy6xykG+IflgcVoOjQuWa9vUoDzhScRY90+RKjd5TXh9UK0Z+oJ0DTXsg1HUKeq RRaLUid+p+HMzRnKyJBGgXOo2lss/wcqwW7ZOq1orTTYpszCQotlCGLlnGm/73XOd6oh xqcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744657224; x=1745262024; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BM9zwBpaPC50zA2czQ1RcEEwRBmd8ElcrZUeF7ivEoo=; b=jDT3KIKJevq1WR9wM0wWQoTdSrpJeIW0q3e+ByIkIgdUsbOI+hWi/biF8fvvGMfVxF fgsQXXYMOPIlpGSwia+9vPZWxGJRyMaxhIWqf4+AbsTq6AGtRcjmvBswrjrrET/JmGIC 1q0hyUbmd7md8cVE3+t5lFSssRDVtfCbcmjIHVqAHoBY9GjWIi15hkvakQ6SII8uOSRi nM3beP+WEdteXpGPQFOT2ltXtPlHJ5fzyXcIhcpF2N48EwSCLZ4iTUd/dmE8YczOLSbI /fsjWMn0qCmhPb3OdokfeVI+mjgxrPVmOPBX5C309tQoZlOL3fwV+BJdBWTvvZvMGodv 39zg== X-Gm-Message-State: AOJu0Yys67mluBfogS3dLFtGm05ucy/6TFAobcCNqxz5DMn8G9LLQR5N /TUbQvurUeyQAb8H8RyPZBCl6RQ1SyU61Sdc7fxiSoWRDNlF0kE= X-Gm-Gg: ASbGncsCjmhjN1tW7z1WiGJrilE1tItfwafHmbTU8jyCUzd2X4BkQoRMXsVZBpQfhOG q3KYXr6ndEasvAYgPoRtazkgWR/Nyzv5/jkBIwtjcIf0MKNvXcszKo4Y2iNOK/XJqpprvm9NlkI xf6JiPeoMVBSZ/oIVfHFDCC0or3/+NVS/1+cx4KshROaSSB8ihRY7cvxDEP6aPUtjXBmnvOKAtj SFOBrys/Nfj+TxKFSA5L15h7yvzeUqhto/myjiwbHGNrKuKXfZYTmI1gyakjMTlcbHIqoIR5vNG KJ6oi56pkQL/7ZNA0GExm96ftjPDmA== X-Google-Smtp-Source: AGHT+IG/S7N5dneTrlg0/ywqFMQr8w5oTSy2rAhEkzpRuSIVCef6v3Nqtqgg3LwLw5jNJ/aCowxjYw== X-Received: by 2002:a05:6512:1316:b0:545:4d1:64c0 with SMTP id 2adb3069b0e04-54d4529da7amr3648356e87.27.1744657223785; Mon, 14 Apr 2025 12:00:23 -0700 (PDT) Received: from ark.local ([2a09:bac5:5151:2373::388:90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54d3d51d606sm1180796e87.214.2025.04.14.12.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Apr 2025 12:00:23 -0700 (PDT) Received: by ark.local (Postfix, from userid 1000) id 41864F20074; Mon, 14 Apr 2025 22:00:22 +0300 (MSK) Date: Mon, 14 Apr 2025 22:00:22 +0300 From: Konstantin Osipov To: Kirill Reshke Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Built-in Raft replication Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk * Kirill Reshke [25/04/14 20:48]: > > I am considering starting work on implementing a built-in Raft > > replication for PostgreSQL. > > > > Just some thought on top of my mind, if you need my voice here: > > I have a hard time believing the community will be positive about this > change in-core. It has more changes as contrib extension. In fact, if > we want a built-in consensus algorithm, Paxos is a better option, > because you can use postgresql as local crash-safe storage for single > decree paxos, just store your state (ballot number, last voice) in a > heap table. But Raft is a log replication algorithm, not a consensus algorithm. It does use consensus, but that's for leader election. Paxos could be used for log replication, but that would be expensive. In fact etcd uses Raft, and etcd is used by Patroni. So I completely lost your line of thought here. > OTOH Raft needs to write its own log, and what's worse, it sometimes > needs to remove already written parts of it (so, it is not appended > only, unlike WAL). If you have a production system which maintains two > kinds of logs with different semantics, it is a very hard system to > maintain.. My proposal is exactly to replace (or rather, extend) the current synchronous log replication with Raft. Entry removal is possible to stack on top of append-only format, and production implementations exist which do that. So, no, it's a single log, and in fact the current WAL will do. > There is actually a prod-ready (non open source) implementation of > RAFT as extension, called BiHA, by pgpro. My guess biha is an extension since a proprietary code is easier to maintain that way. I'd rather say the fact that there is a proprietary implementation out in the field confirms it could be a good idea to have it in PostgreSQL trunk. In any case I'm interested in contributing to the trunk, not building a proprietary module/fork. -- Konstantin Osipov