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 1t97Us-007sPG-7o for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Nov 2024 18:44:45 +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 1t97Up-001Cr1-Fb for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Nov 2024 18:44:44 +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 1t97Up-001Cqr-5K for pgsql-hackers@lists.postgresql.org; Thu, 07 Nov 2024 18:44:43 +0000 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t97Uk-000id9-EG for pgsql-hackers@postgresql.org; Thu, 07 Nov 2024 18:44:42 +0000 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3e6104701ffso901422b6e.0 for ; Thu, 07 Nov 2024 10:44:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1731005077; x=1731609877; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ARvEIUGNxq9M/fImqyuxKIl3maQRkYzrO/rgnCrnl0Q=; b=LbiQfJmLpQUOx+205phlM9lwhxLPqgnkWbn/u72ty+8s38JwUZi00DfAtTSqA3PnlQ ug0GXSQabHBtRBoaF2U6xFneQkBASeAHesmOpgcprLN+/gU0LP3RAlVyDRQpfmW9Enxq 1jocRvjsi/JNtvrdktdoWBLbZLLy2TFVOmjuKqjEvDB3JRqXNq1RjT7IW3k7/5NrrTt6 Np0nNw2jkikCz8Y6lEd3py6f92LwtDlV5JIIUoRXtwKc6pnM2qnMGIBhFpPiIBIIgm5z wOoC9CNaZXJSk7roKeSNKVdJx4AgY6dhkqXG+OlqCEnrpQZdhqrZx/xDaU/GzX7AdFNi lKzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731005077; x=1731609877; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ARvEIUGNxq9M/fImqyuxKIl3maQRkYzrO/rgnCrnl0Q=; b=kPT5fjTs/78mass/OGbklQNKjcGLB2hvKBNf8XPuhJXUEHtAYSiBZZh1wY8+ah7wjT pqNr3vtF0mRTWhCKt8NiBvq1NIf5Sc1xL8QAF5OHvN9SvnvlCV8Ml8oQ58Moiuhq1YyI 9L6btfoNp5JDAvToCh4JLvhi+x4PELKsPV5ZspXKno/UcyAMD1L3sueD1UQOGU3u7XBR lXXs7KlcFb6OQSg9bVc2vnGvuz1nVaPXkk8/V7Dp+jct6sPTD04H4PhBl8IIDF3vGP35 swr8/zKWnKiMhyPb5vqeo6SX5EkpAfr+RYK44eHubnm4NI/Ctp1/qaYSd9FRk5OIdHCz 7aww== X-Forwarded-Encrypted: i=1; AJvYcCVkF6o/D8YjJSXJWDAogTgW3EEAobgYnqjGf24CfyM9UnevSCAlbreJqhof3yZ8v+tamMD3CBqmMK9S48l9@postgresql.org X-Gm-Message-State: AOJu0YycPg09CQkOFL/XWRKM3hO4lmkMHFqqqPqVXeIV9A3y6DStG6pZ Qc7PUA31okr5Orp3PZr0tnsKHOtD3Avb5tAbbb9FNJkhnKiPo4qPLk1HeMbK4GSdeCpuuzs5Hxr aTyuTJrKx9kqWBjlKvbOjn0tNW6JzYmc53kzg X-Google-Smtp-Source: AGHT+IFv/Yiy+GUTTkEjPGUrog5EFEEU2G8pmoblrNTfwWHroN+GtdW61gEMcEwLGPIvEf5YPb63CWPr0OvSBLn+CaY= X-Received: by 2002:a05:6870:9111:b0:270:184b:ccd9 with SMTP id 586e51a60fabf-29051e1d5femr39759616fac.39.1731005077097; Thu, 07 Nov 2024 10:44:37 -0800 (PST) MIME-Version: 1.0 References: <20240910172712.e8.nmisch@google.com> <20240910205850.5d.nmisch@google.com> <20240913145621.43.nmisch@google.com> In-Reply-To: From: Jacob Champion Date: Thu, 7 Nov 2024 10:44:25 -0800 Message-ID: Subject: Re: [PATCH] pg_stat_activity: make slow/hanging authentication more visible To: Andres Freund Cc: Michael Paquier , Robert Haas , Noah Misch , Andrew Dunstan , PostgreSQL Hackers , Euler Taveira Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Nov 7, 2024 at 10:12=E2=80=AFAM Andres Freund = wrote: > I don't understand why the pgstat_bestart()/pgstat_bestart_pre_auth() spl= it > makes sense. The latter is going to redo most of the work that the former > did. What's the point of that? > > Why not have a new function that initializes just the missing additional > information? Or for that matter, why not move most of what pgstat_bestart= () > does into pgstat_beinit()? I talk about that up above [1]. I agree that this is all complicated and fragile, but at the moment, I think splitting things apart is not going to reduce the complexity in any way. I'm all ears for a different approach, though (and it sounds like Michael is taking a stab at it too). > This doesn't really seem like it's actually using wait events to describe > waits. The new wait events cover stuff like memory allocations etc, see > e.g. pg_SSPI_make_upn(). I've also asked about the "scope" of the waits in the OP [2]. I can move them downwards in the stack, if you'd prefer. All of these are intended to cover parts of the code that can actually hang, but for things like SSPI I'm just working off of inspection and Win32 documentation. So if it's not actually true that some of these call points can hang, let me know and I can remove them. (For the particular example you called out, I'm just trying to cover both calls to TranslateName() in a maintainable place. The documentation says "TranslateName fails if it cannot bind to Active Directory on a domain controller." which seemed pretty wait-worthy to me.) > This isn't just pedantry - all the relevant code really needs to be rewri= tten > to allow the blocking to happen in an interruptible way, otherwise > authentication timeout etc can't realiably work. Once that's done you can > actually define useful wait events too. I agree that would be amazing! I'm not about to tackle reliable interrupts for all of the current blocking auth code for v18, though. I'm just trying to make it observable when we do something that blocks. --Jacob [1] https://www.postgresql.org/message-id/CAOYmi%2BkLzSWrDHZbJg8bWZ94oP_K98= mkoEvetgupOBVoy5H_ag%40mail.gmail.com [2] https://www.postgresql.org/message-id/CAOYmi%2B%3D60deN20WDyCoHCiecgivJ= xr%3D98s7s7-C8SkXwrCfHXg%40mail.gmail.com