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 1t5pET-008naY-Gm for pgsql-general@arkaria.postgresql.org; Tue, 29 Oct 2024 16:38:13 +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 1t5pER-000LUO-RL for pgsql-general@arkaria.postgresql.org; Tue, 29 Oct 2024 16:38:12 +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 1t5pER-000LUF-Gt for pgsql-general@lists.postgresql.org; Tue, 29 Oct 2024 16:38:11 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t5pEP-003chJ-Hc for pgsql-general@lists.postgresql.org; Tue, 29 Oct 2024 16:38:11 +0000 Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfhigh.phl.internal (Postfix) with ESMTP id 4613C1140194; Tue, 29 Oct 2024 12:38:07 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Tue, 29 Oct 2024 12:38:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= 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:subject:subject:to:to; s=fm2; t=1730219887; x=1730306287; bh=SSPIBVH9+mlD2PKaxJFGa0l4SwnfuzNRgiYpjEbLl04=; b= UDrUfTPuGNHj+UNU3GWqhnCow8pzxsEXupapTvH11HkAeInjwmpCMTpGzNOOC7X5 oxoMEIIwfQogJPTJUkaeUGFURSAJCq/kbvCf1Mywptbti9jOjwBKC5TedjPTcyPo wtH3rIDLID3m7Ji3P3kXI0Vj541Eh4hVxME1opihZTq0mY7DycjDZ/FF248+pAFI jhOeoDHEb+tJbahMtVequ3DtieLbWU6b/uzETafOJwGhf5ArndGcJNYlRugr6b5s xZ3XUxW6IxKPfj5DJlZnLbquhrLkq4rRIKCTBmywRrksGBzmt8ldmdjkzZMRDhDI gbPTUN3CwlGAk7HExCV9kw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1730219887; x=1730306287; bh=S SPIBVH9+mlD2PKaxJFGa0l4SwnfuzNRgiYpjEbLl04=; b=XRYugymWf3yivqSCn 6w2OQc+JrDJVKYue+RpVMYj7wgdRrCu9B3oPptNbgrScTmNk2HnUPtK47kpXvS7Q a0RHkp2TVOqghoPXL+4UUKs+QiaOkvxofgVMhi4/KUR6j35up6hX8gYQesDG4woV phzlSh3dfQp7ZQgyrpeRUz6V6qdynlzG6rX33hc3RX/SihANHy+Klm+WgggjI72u ZQWRsLKS4A2t6uRMp5wAMX8lat9XAQI1UWffUk3pPJQKM6+KGlLD0CIVmxvb7I2N jC5rO3jz0niZ1y4F973JE0VTSs+gZOaXa2/7jGmLTPy1tTZlOx6GChMWBgj9RNTH 25qHw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdekuddgkeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvfhfhjggtgfesthejredttddvjeen ucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrse grkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpefhudfgfefggeeufeejgeev keelfefgvdelteffteetueffkeeuleeiveffleehtdenucffohhmrghinhepvhgvrhhsih honhdrtggrthenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhr ohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmpdhnsggprhgtph htthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegurghnihgvlhdrfigv shhtvghrmhgrnhhnsegusghiqdhsvghrvhhitggvshdrtghomhdprhgtphhtthhopehpgh hsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 29 Oct 2024 12:38:06 -0400 (EDT) Message-ID: <792f687d-5188-4beb-b94b-3d3edeb384a3@aklaver.com> Date: Tue, 29 Oct 2024 09:38:05 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Delays between "connection received" and "connection authenticated" because of localhost entries in hba To: "Daniel Westermann (DWE)" , "pgsql-general@lists.postgresql.org" References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/29/24 09:30, Daniel Westermann (DWE) wrote: > Delays between "connection received" and "connection authenticated" because of localhost entries in hba > > Hi, > > we're facing a strange issue with delays between "connection received" and "connection authenticated". > > # select version(); > version > ----------------------------------------------------------------------------------------------------------------------------------- > PostgreSQL 15.6 (Ubuntu 15.6-1.pgdg22.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit > (1 ligne) > > I know, this is not the latest minor version. > > # \! cat /etc/os-release | head -1 > PRETTY_NAME="Ubuntu 22.04.4 LTS" > > What we see in the log is this (around 4 seconds delay): > > 2024-05-07 15:29:50.244 CEST [369909] LOG: connection received: host=xx.xx.xx.100 port=48434 > 2024-05-07 15:29:54.518 CEST [369909] LOG: connection authenticated: identity="xxxxxx" method=md5 (/etc/postgresql/15/main/pg_hba.conf:121) 1) host=xx.xx.xx.100 = localhost? 2) In postgresql.conf what is listen_addresses set to? 3) What are the settings in /etc/hosts? > > The matching line is this ( I know md5 ): > host all xxxxx xx.xx.xx.0/24 md5 > > What we've found out so far is, that this only happens if we have a localhost(or any other hostname) line before the line matching our connection, something like this: > host replication xxxxx localhost md5 > host all xxxxx xx.xx.xx.0/24 md5 > > We don't see it if we do it like this: > host all xxxxx xx.xx.xx.0/24 md5 > host replication xxxxx localhost md5 > > Has anyone experienced such a behavior? It seems clear that this is somehow related to name resolution but we couldn't reproduce something like this on the OS using dig (in a loop several hundred of times). It is also only happening from time to time, and not constantly. > > What we're basically looking for is a way to prove the assumption without involving PostgreSQL at all, if that does make sense? > > Many thanks in advance > Daniel > > -- Adrian Klaver adrian.klaver@aklaver.com