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 1tqIHj-002X6N-TT for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Mar 2025 20:57:40 +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 1tqIHi-008cRJ-Gx for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Mar 2025 20:57:38 +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 1tqIHi-008cR6-67 for pgsql-hackers@lists.postgresql.org; Thu, 06 Mar 2025 20:57:38 +0000 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tqIHg-001N4x-01 for pgsql-hackers@postgresql.org; Thu, 06 Mar 2025 20:57:37 +0000 Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-7c3cb761402so206893285a.0 for ; Thu, 06 Mar 2025 12:57:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1741294655; x=1741899455; 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=rx38nttjgIXHztmzt9wywmu9mEP4Yy+YrNCls3rd9ec=; b=VspXpo62WPADEAfeqiLon/zqHNYO0DiCHGi7/qInTEMUiHtkrXjuO/fYnLLEuPx58K D4dfDgAF1jCCo7cTjNbDX/zr7iSRZimLYaLTsTrZBsgU7PUMsy4hpXu0MABqTHSXO+0f cma8EjPFyjtsnWpiyg6ZXHT+FZgl8LVWLsU5eDRvYbhzJ64IUY4EEjh7cTqQfSa6/IqF ugKhfQevvFCvpXBQ7AdCUalS3gl63EsFM0e4BCET1n5jqEc8xQv35rNZ2D8dVtRUs4tP IF2S/2H9sDiTguQ1a3dVxr28ZQQlRJUCoGLja5oj4/LAbl4vXUsCicEAAVQsBTbyUFPf pt1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741294655; x=1741899455; 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=rx38nttjgIXHztmzt9wywmu9mEP4Yy+YrNCls3rd9ec=; b=cPf9gyv0uPIfiXcjkVnH1qtOMZTd2ZhzoRFP8vhWt6h34wt2YV15XXoq9if0+1IsTp a6P9bxp59Ha7AL8E7cW9GOvX4WAzdQo5P37NC8pHa37wcRruwM56zvZ88DZGoNBDc8NQ SkxtANwdvs69Gl2opt2WVH/Mp3YumXEKnQ7XyBmglGM2hy/R/5jZEoLbCYJjNMCRw+OT rYXoNU1E2PBaZsNlzrrVDxY1WxyGL+duh/1w8KgHUNLcBaDDh8FfTrJ5lTx05cJxpkwH uocsXcY6gn0P8YuENTGBLLxiaVxjJR79K40ldI8STye4jvOKrwkiZR3RXXpmZebqzjLq AmVQ== X-Forwarded-Encrypted: i=1; AJvYcCVsfxGlhLW5I+vE7Qif3GNcAvmRPj24PXzuFenn0A4qUq9PHicav9qMVjKfF+hw5Ci+J+TbHZpUmRX/jXVw@postgresql.org X-Gm-Message-State: AOJu0YwMp2FK0Affq4LtWZYzSNQvi0j1GjzSEuONCV7Fkgu7AR39zHgJ V86At0aKGu5octH+tJsRP1FgYMahs3efiAzvgpS2zplM2OCMIW2cDpqCnGRW/piImVj6Txn/Eh0 IUnCPTt43LL+E1Q/jMZhyisbJrCv21H514Nkp X-Gm-Gg: ASbGncu7binsK/n8M0FhU0fQ2vte/Mo4ahsgeYeDFSBue1giLGqY9MHsgwMWlfVj6aC AY5SpTUXhHkFTJNTzx45JaTe7K9SnM2ojpb6FeMp+Y44HAAKBtiWkCEmjW1l3RbNhFZPKEkIKbQ mNckAofFQeDn4HhOGjCw5/KkPJ X-Google-Smtp-Source: AGHT+IERyGpcjZ3w0kOCtt/Ay3Hj05NpeTavGw5cPHNbA2exx+W5+rAz+lqppZxakNi3zvuuJZLM39MZAkWvOdDhYlQ= X-Received: by 2002:a05:6214:1c49:b0:6e8:fa72:be47 with SMTP id 6a1803df08f44-6e900604eaamr7406776d6.8.1741294655095; Thu, 06 Mar 2025 12:57:35 -0800 (PST) MIME-Version: 1.0 References: <83C44AB4-24B0-437F-B139-B5CBC5821BB1@yesql.se> <2A1511A0-C04B-47E4-B1C3-54C2A1C765B8@yesql.se> <13F329B6-86BC-40A5-96F4-102784A0357A@yesql.se> In-Reply-To: From: Jacob Champion Date: Thu, 6 Mar 2025 12:57:24 -0800 X-Gm-Features: AQ5f1JppmTHcX_JOVohCWWx-pzNsQ_HA05bQ7VA1MTG9SQVa2fYMIRzbjRRgIgQ Message-ID: Subject: Re: [PoC] Federated Authn/z with OAUTHBEARER To: Thomas Munro Cc: Andres Freund , Daniel Gustafsson , Peter Eisentraut , Antonin Houska , PostgreSQL Hackers 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 Tue, Mar 4, 2025 at 2:44=E2=80=AFPM Jacob Champion wrote: > Maybe. My first attempt gets all the BSDs green except macOS -- which > now fails in a completely different test, haha... -_- Small update: there is not one bug, but three that interact. =E0=B2=A0_=E0= =B2=A0 1) The test server advertises an issuer of `https://localhost:`, but it doesn't listen on all localhost interfaces. When Curl tries to contact the issuer on IPv6, its Happy Eyeballs handling usually falls back to IPv4 after discovering that IPv6 is nonfunctional, but occasionally it contacts something that was temporarily listening there instead. Since I don't really want to write a bunch of IPv6 fallback code for the test server -- this should be testing OAuth, not finding all the ways that buildfarm OSes can expose dual stack sockets -- I changed the issuer to be IPv4-only. When I did this, the interval timing tests immediately failed on macOS. 2) macOS's EVFILT_TIMER implementation seems to be different from the other BSDs. On Mac, when you re-add a timer to a kqueue, any existing timer-fired events for it are not cleared out and the kqueue might remain readable. This breaks a postcondition of our set_timer() function, which is that new timeouts are supposed to completely replace previous timeouts. With a dual stack issuer, the Happy Eyeballs timeouts would be routinely cleared out by libcurl, setting up a clean slate for the next call to set_timer(). But with an IPv4-only issuer, libcurl didn't need to clear out the timeouts (they'd already fired), which meant that our call to set the ping interval was ineffective. 3) There is a related performance bug on other platforms. If a Curl timeout happens partway through a request (so libcurl won't clear it), the timer-expired event will stay set and CPU will be burned to spin pointlessly on drive_request(). This is much easier to notice after taking Happy Eyeballs out of the picture. It doesn't cause logical failures -- Curl basically discards the unnecessary calls -- but it's definitely unintended. -- Problem 1 is a simple patch. I am working on a fix for Problem 2, but I got stuck trying to get a "perfect" solution working yesterday... Since this is a partial(?) blocker for getting NetBSD going, I'm going to pivot to an ugly-but-simple approach today. I plan to defer working on Problem 3, which should just be a performance bug, until the tests are green again. And I would like to eventually add some stronger unit tests for the timer behavior, to catch other potential OS-specific problems in the future. Thanks, --Jacob