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 1u4eGh-005IOg-Gf for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Apr 2025 11:15:55 +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 1u4eGe-008Pha-86 for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Apr 2025 11:15:53 +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 1u4eFS-008LzD-Ok for pgsql-hackers@lists.postgresql.org; Tue, 15 Apr 2025 11:14:39 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u4eFQ-000CaK-1g for pgsql-hackers@lists.postgresql.org; Tue, 15 Apr 2025 11:14:39 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-549946c5346so6106252e87.2 for ; Tue, 15 Apr 2025 04:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744715676; x=1745320476; 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=bWokEoBLiyyVcM4VT/hxrE8dKH+/tXPwALOxuxSmJFg=; b=LbV4MPlD3lF1lfwyAeeYlE0fz63FDyTMDecsrgGXNbySonNfnLOo55uR58/zr/Q7KM vdxx29OIhs3XCYJTErXfIZD2tYZSORncHnJn/05LboXgOsciyl8SLrK3ZYfBUXhtO0e7 foLcXlE5VICiNkUuPKoip5AHDXc8DVnBAkKbLvJ/HkyrpyvwfLRhRVzCeyNvI1KdmNya xJt9jHa1xzoFYFuuVIEzo/aYv3n4U3iUBo7w11c6EOvERcNVCala4wgF3dr8Ccvs43iX LvgQProRkRY4Fx7jF0/zxoHY72DrsIpBoVGWZQpjtH0MjIyEZDIaRx2iJJcUdxGncAJO nrXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744715676; x=1745320476; 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=bWokEoBLiyyVcM4VT/hxrE8dKH+/tXPwALOxuxSmJFg=; b=bl+nGFkFV0fypRcKoL1uNrqZm1BXAMFQ4Ga5GbmPWttPoZOiDo+jJJT3fxJmtwxcV+ HTxSOcmyifeo+Nb7Kx1Alevz+c1nxK64/57WEIYoUKs8XljaNKxFFVoKe6BDavZlA2X8 dXCUldd6pzY9EmTyyl47VNfXBEP+sSO5vAOjvquaLDpUQrpppw0AcwPB3L16zgON9Hf0 jI+iHA7ivTTa5Tsc7D/+50HBjn+kSa6MqyCYL9JC+9NuxvTFXaN7mQF1ZoxE9iSxqBec 4qXK7+KAvjlLWVHM/4PrlpElQZB8i/is6cq1lBs67vUQU4k9rGZgiu8+jCaRu9iSLhqO zwPg== X-Forwarded-Encrypted: i=1; AJvYcCW4BPYvmNKNAfJjAUnp8m287i9nRSu+j8id0k5flyI8lnoEVqe54rnhD9vXW/yDPv4M9CVkGbvKLZxjj28J@lists.postgresql.org X-Gm-Message-State: AOJu0Yz75viDSyNEK20nMdf/7Q9By26zN83hekfgg4hc2f9rFFbIkefD pKAzQ/hZTxrnpz0P8EOiMCHC5CV9A61ZZaiiNbodb/+SRDFCCDU= X-Gm-Gg: ASbGncumGytOhYXMzcEcBFdmOc6oTboFPvngFGaEgTcb0YLnOhR4h9kPHWguZDdfgxT Bg746MG3nUXKO89LSq6zlgB/ldqbR1+a2oAQC8MU0krQTRHh2geUM8P1ompRXX2bi58AvG8tRuV 0mbtSd6feqZ8keDe9+PWF8faPuVadZsiHp2qtZtiNBfQgS7+Dp4tMW+JT+eNsJqT48rBg8EVYrK zyggmTJAX0CWmVja17MDFSGYQOWtmW99811aWrofb9V26fjaIl52OcqrlJRCO7w7jWs8bZtBet7 WGkOvoIaX7TJ6bHYeCcdVZrmL4sdKQ== X-Google-Smtp-Source: AGHT+IGgrtcJfWSWMdzm52qWwazwNaDZeY/dGxNiGaFERFx88rpOpNbqZq9cck69+MQYF5IrteSYTw== X-Received: by 2002:a05:6512:ac1:b0:549:9143:2609 with SMTP id 2adb3069b0e04-54d4528a9c2mr5097257e87.3.1744715676013; Tue, 15 Apr 2025 04:14:36 -0700 (PDT) Received: from ark.local ([2a09:bac5:5151:2369::387:4c]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54d3d5025ffsm1384939e87.116.2025.04.15.04.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Apr 2025 04:14:35 -0700 (PDT) Received: by ark.local (Postfix, from userid 1000) id 0AB85F20074; Tue, 15 Apr 2025 14:14:35 +0300 (MSK) Date: Tue, 15 Apr 2025 14:14:35 +0300 From: Konstantin Osipov To: Yura Sokolov Cc: Kirill Reshke , pgsql-hackers@lists.postgresql.org Subject: Re: Built-in Raft replication Message-ID: References: <142418c4-5db1-4221-a0a4-cd8aa9a17e83@postgrespro.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <142418c4-5db1-4221-a0a4-cd8aa9a17e83@postgrespro.ru> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk * Yura Sokolov [25/04/15 12:02]: > > 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.. > > Raft is log replication protocol which uses log position and term. > But... PostgreSQL already have log position and term in its WAL structure. > PostgreSQL's timeline is actually the Term. > Raft implementer needs just to correct rules for Term/Timeline switching: > - instead of "next TimeLine number is just increment of largest known > TimeLine number" it needs to be "next TimeLine number is the result of > Leader Election". > > And yes, "it sometimes needs to remove already written parts of it". > But... It is exactly what every PostgreSQL's cluster manager software have > to do to join previous leader as a follower to new leader - pg_rewind. > > So, PostgreSQL already have 70-90%% of Raft implementation details. > Raft doesn't have to be implemented in PostgreSQL. > Raft has to be finished!!! > > PS: One of the biggest issues is forced snapshot on replica promotion. It > really slows down leader switch time. It looks like it is not really > needed, or some small workaround should be enough. I'd say my pet peeve is storing the cluster topology (the so called raft configuration) inside the database, not in an external state provider. Agree on other points. -- Konstantin Osipov