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 1r8nlB-00BmEM-R6 for pgsql-general@arkaria.postgresql.org; Thu, 30 Nov 2023 20:35:46 +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 1r8nlA-002lvz-5J for pgsql-general@arkaria.postgresql.org; Thu, 30 Nov 2023 20:35:44 +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 1r8nl9-002lvn-5P for pgsql-general@lists.postgresql.org; Thu, 30 Nov 2023 20:35:43 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r8nl3-008A3S-O1 for pgsql-general@postgresql.org; Thu, 30 Nov 2023 20:35:41 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id ED6DD3200A28; Thu, 30 Nov 2023 15:35:35 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 30 Nov 2023 15:35:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1701376535; x=1701462935; bh=mZ8sl9UGkeYtB5tuwV+L9wxEEo9SeAd5J8t 0vN1VHAw=; b=Qqr9ouaCUgsUKiHJjAoIe+LfhtYQxwW7CgRpOKZzJL6Ht/DtlbN q7g/6MMI5GmLrE84ooPk+5KhMG1E6b+YN/K59vK6Mb0CivB4PAX6SLZrkssH68e5 /3xSrn3pNlpRnvhTDN4tzxrFjK0j44mJ6tzCpO/0sQ5vcHZw/DsMR+DYj9FstPEc fBCl1zTRKzrcS6ttuw3jPH4z5Fg0MmjnnXb3T6AS0v5zCnscZc0ON4KikRi31qPZ lbU7URY0fnRWbb0MNnlgSG/luhtCCKqq6/+dnuEbQGvGb2TqkRw2olUJ05KHSwQ6 JWKK44Xe9s/qmxMILQ71cu3Gb3j7j7uw1XQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1701376535; x=1701462935; bh=mZ8sl9UGkeYtB5tuwV+L9wxEEo9SeAd5J8t 0vN1VHAw=; b=i7uSakrLBPIMmgwwKJwEEI2Cb255GvERDRfIfOKkwUOEdr8TOGE Q5+cnXAq9lIe/teiTOJ6k8sfsg+Cux5bJq24LcMevf3D5beZzXiCSIL4qsVDfJzi R0MKd4cY6mEzKnaN3ER8y88OTnYwCZ/cn+L8wzM2Gz3GgOVKa/aK7jcBN8aPFgV1 u2An1vo+lzd1a+t7buHFTUoZdWTV4XSXya4WvgS9xHI6cGvIqJqfTLGa/DHRgpFZ USCCxyye+dIzjNVgdQX/NLdAg4Jsk69bDL3Y6Fk5p7Xz8sWOcqxQ2o7lOB7AOQMj fbNq1sCztSkgFkpystZagIv5CN5ccmRYm2w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeijedgudefkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffhvfevfhgjtgfgse htkeertddtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghn rdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepgeejke efhffgudejhefhhfejkefgheeivdeujeejudfggfeggefftdfhtdeutdeknecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklh grvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 30 Nov 2023 15:35:34 -0500 (EST) Message-ID: <1b893a10-1dfd-4abf-b066-9b544c2fa985@aklaver.com> Date: Thu, 30 Nov 2023 12:35:34 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Two started cluster on the same data directory and port Content-Language: en-US From: Adrian Klaver To: Loles Cc: PostgreSQL References: <477f32ab-72cc-4888-835a-0f25aa3db705@aklaver.com> <10c26017-62f2-457e-b71c-c53eada6ae5b@aklaver.com> <7280c019-2c61-452c-be52-bf38604df356@aklaver.com> In-Reply-To: <7280c019-2c61-452c-be52-bf38604df356@aklaver.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/30/23 10:35, Adrian Klaver wrote: > On 11/30/23 09:27, Loles wrote: > >> root@hostname:~# pg_lsclusters >> Ver Cluster  Port Status Owner    Data directory              Log file >> *14  main     5432 online* postgres /var/lib/postgresql/14/main >> /var/log/postgresql/postgresql-14-main.log >> *14  main_old 5432 online *postgres /var/lib/postgresql/14/main >> /var/log/postgresql/postgresql-14-main_old.log >> >> Start, up the two cluster. >> > > Before going any further make sure you have a current backup of the > database. > > Hmm, are /etc/postgresql/14/main/ and /etc/postgresql/14/main_old/ > symlinked together? > > If not what if you move the ~14/main_old/ directory somewhere else and > then restart Postgres? Alright results of testing here: tree /etc/postgresql/14 /etc/postgresql/14 ├── main │   ├── conf.d │   ├── environment │   ├── pg_ctl.conf │   ├── pg_hba.conf │   ├── pg_ident.conf │   ├── postgresql.conf │   └── start.conf └── main_old ├── conf.d ├── environment ├── pg_ctl.conf ├── pg_hba.conf ├── pg_ident.conf ├── postgresql.conf └── start.conf Where I just copied main/ to main_old/. sudo pg_ctlcluster start 14 main pg_lsclusters Ver Cluster Port Status Owner Data directory Log file 14 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log 14 main_old 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main_old.log sudo pg_ctlcluster stop 14 main pg_lsclusters Ver Cluster Port Status Owner Data directory Log file 14 main 5432 down postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log 14 main_old 5432 down postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main_old.log cd /etc/postgresql/14/ sudo rm -r main_old/ or sudo cp -r main_old sudo pg_ctlcluster start 14 main pg_lsclusters Ver Cluster Port Status Owner Data directory Log file 14 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log I would need to understand systemd better to be sure, but I'm thinking the duplicated cluster are happening here: /lib/systemd/system-generators/postgresql-generator #!/bin/sh # This systemd generator creates dependency symlinks that make all PostgreSQL # clusters with "auto" in their start.conf file be started/stopped/reloaded # when postgresql.service is started/stopped/reloaded. set -eu gendir="$1" wantdir="$1/postgresql.service.wants" bindir="/usr/lib/postgresql/" #redhat# bindir="/usr/pgsql-" pgservice="/lib/systemd/system/postgresql@.service" mkdir -p "$wantdir" for conf in /etc/postgresql/*/*/postgresql.conf; do # abort loop if glob was not expanded (but accept dead symlinks) if ! test -e "$conf" && ! test -L "$conf"; then continue; fi dir="${conf%/*}" # evaluate start.conf if [ -e "$dir/start.conf" ]; then start=$(sed 's/#.*$//; /^[[:space:]]*$/d; s/^\s*//; s/\s*$//' "$dir/start.conf") else start=auto fi [ "$start" = "auto" ] || continue verdir="${dir%/*}" version="${verdir##*/}" test -x "$bindir$version/bin/postgres" || continue # package got removed cluster="${dir##*/}" ln -s "$pgservice" "$wantdir/postgresql@$version-$cluster.service" done exit 0 > > Adrian Klaver > adrian.klaver@aklaver.com > > > -- Adrian Klaver adrian.klaver@aklaver.com