Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxTRt-0005gm-7v for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Aug 2019 09:50:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxTRr-0003iw-WA for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Aug 2019 09:50:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxTRr-0003io-Lf for pgsql-hackers@lists.postgresql.org; Tue, 13 Aug 2019 09:50:35 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxTRo-0005Ki-NT for pgsql-hackers@postgresql.org; Tue, 13 Aug 2019 09:50:35 +0000 Received: by mail-ed1-x544.google.com with SMTP id h8so18233754edv.7 for ; Tue, 13 Aug 2019 02:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=JMU9jC1xZE+BxnHJYiYMM/5+sF1yI3Y3FdehPuzOIek=; b=uFG0u2FHGM7tW78jKwhc5H8w5xD6VbuU4iKSk3ta+jNV5ohW7AqPDo3O5xZ8wym5gE derACm0XETtfJ5pL6CJrcZONnAw+6ifdkhI8kZZGpBWsQ6pfGymKdMzRxqn1sc0hHSqC 11AYPx3wBZ/4UrnXNfGf0IKjWKSFETyNYgUP0k+uFVXa3F/kdj8z2Sgu+LEfspWF72hB qNpJB78yslWGXLxn6iv8DRe30l05uDRikAs6ZWSIVxRmDLr7/JQxueNnCMQt833AvyuC 2JbnIfEQ+u1exXp67HkNOaTtQR48szNwQxEJRCCqeluTOEJEY2csAEsrdG6q80DHyR9H RyYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=JMU9jC1xZE+BxnHJYiYMM/5+sF1yI3Y3FdehPuzOIek=; b=kGb/W6Srg+QjrVx7jsAAt1quqEpAvttK4aQrxzdoJCVx2fu2A0pAnaUBesZrO63rFL DgE+9tLb9fxtfWZc+ELeXOp3djOn/ag2K0PSLpUEp7dN2raXgcfHJG2Ov/Mky5Kgeg/Z 8k4XQ1ErB3iCZGCoN6Uvy84ycC1SlOYAWh0Y1IDGHbI5MUpTOYCxkB9xdibwQKnaySh8 27L5tXdxt90Yqd1PYi0E2Tx9ucjQ0WfO99VaDl9qn0MRTRdG2w9OqxPgjgE5w0epAeMI dzeH34ECVOpbHNxqvJCAbLtx9NaPD4IWTddyxuF6ZABVVAdAzYqxnuOmTfndzCB5ullQ ZyAQ== X-Gm-Message-State: APjAAAWtk40heQPn0Ot5i4lpx2h9vYUr75FJwXUiXmH+olLD23DHe+cS Q1JEwB0JTE/kpI/f/cj4Qu8WzS/1Y58tFVZMP8Kik9hU/Ig= X-Google-Smtp-Source: APXvYqyNbQihZkFxhctMNdG1qD4ZBnOcqR9pHvIak3xUP9Voa9fWH0iRSswbmlqVkDwaAKreeM1nTDZhQicXraZ+miU= X-Received: by 2002:a17:906:d183:: with SMTP id c3mr35311820ejz.149.1565689831387; Tue, 13 Aug 2019 02:50:31 -0700 (PDT) MIME-Version: 1.0 From: Feike Steenbergen Date: Tue, 13 Aug 2019 11:50:18 +0200 Message-ID: Subject: Feature: Use DNS SRV records for connecting To: PostgreSQL mailing lists Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi all, I'd like to get some feedback on whether or not implementing a DNS SRV feature for connecting to PostgreSQL would be desirable/useful. The main use case is to have a DNS SRV record that lists all the possible primaries of a given replicated PostgreSQL cluster. With auto failover solutions like patroni, pg_auto_failover, stolon, etc. any of these endpoints could be serving the primary server at any point in time. Combined with target_session_attrs a connection string to a highly-available cluster could be something like: psql "dnssrv=mydb.prod.example.com target_session_attr=read_write" Which would then resolve the SRV record _postgresql._tcp.mydb.prod.example.com and using the method described in RFC 2782 connect to the host/port combination one by one until it finds the primary. A benefit of using SRV records would be that the port is also part of the DNS record and therefore a single IP could be used to serve many databases on separate ports. When working with a cloud environment or containerized setup (or both) this would open up some good possibilities. Note: We currently can already do this somehow by specifying multiple hosts/ports in the connection string, however it would be useful if we could refer to a single SRV record instead, as that would have a list of hosts and ports to connect to. DNS SRV is described in detail here: https://tools.ietf.org/html/rfc2782 I'd love to hear some support/dissent, regards, Feike