Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128751 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 5350C1A00BC for ; Wed, 1 Oct 2025 07:28:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1759303654; bh=x81Ci3Rz6AWeAVAAoOouTL+XRbzK7oGh8ZcE+BC7SUw=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=cfQ9wge267uQKQTa/bsq4rQk3nED/q5q5w9NnVbB8E8Vgyd1JVAzf8HMe5ZADnPQv 1SOxQ3JWUEyxDSx7VvCE5blciu+3N2y9fkSUT+ACKbICDfQ3OepcqFn6e+qbWvM93D et4Z5a9CQA+DV0xm+vm5EurwHuyZ7ns59mFJx+zjKU0U7YYTpev7Hx7udEhkOfnZqW hJh/CSEsWggn90Vq7S5o6oOJGAjrLl2d9Oh5CWPqhPjTn5kPvH1op8liPia+olarpc sgrJHmQ1ZviJT2DGqUR9exHgnLYzeCglqaT/kqKC8ZBSg/mLuU4wFI2kNLID5vl+RA Tid/0bhEqCOTw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 15F8718003F for ; Wed, 1 Oct 2025 07:27:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 1 Oct 2025 07:27:30 +0000 (UTC) Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3ece1102998so4646904f8f.2 for ; Wed, 01 Oct 2025 00:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759303728; x=1759908528; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xl6LEiFtWhKzvxIxs6FsEVkRoAAUn7npbGAF58a+zZY=; b=ThU6ffB2rYhh7QlOcvZ4JtKYj3lPr3TrmO3LzwN9mWliMfTCM7qMHR955h413GMbzK grztT2n7gQX3SO8yZbz0KRVZ46zD9oOi9+fJtQoLDI3IJPVSqotlbvWza+aysHrTch8E IF57tZXMjronOCi5L/qx/d4cGL1noIC3/mdyS5BC76I3Szze4MRPRO2YAwZ8V5ah9dCD qomWj4yxA4gZi0cyDC+8nzmAB6aVEiGj7RDqwPABJ9tapNXhfMDc2Q7JLECsq8u/y/bB kYokjL6b7hKYofGfHTXNjes/2qAW87bJsRffX6LVrClKpm7ABRX3YhNL38rS5uAotmw2 gmDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759303728; x=1759908528; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xl6LEiFtWhKzvxIxs6FsEVkRoAAUn7npbGAF58a+zZY=; b=X48hLcuGUrTCtYlcUODr+n83Zrmb0Z00OTNGAvFxqY2qP0MSlXEX22iUREulCmk8IS 0nmX5jnj+1ttgNm4x3VnKpvaf3rYn4FeRGl6wSQlxs790WVd8dUMgdAQggkb7RoEFFwM CfSPRfgdoc4RnMa+4znw0WRJQJOxWBHNIdINrxi1PxZIp/Rv1QXBx2M7DUm10uqKBl4g M/0ESJfe6gBQjDhuqbB38yEwShI0PczGKNAzZNoMn0IbQcZEJvI63gIcnFo6U90EhiFi gN6gX0mG8f9nGe5VlqxYV3B0HlRwoWp8PanfiO/rO+C+iU+Mq7xQJbaGJGWwK1o8tF0k 9Hcg== X-Gm-Message-State: AOJu0YxcSRv5GMs/OlMShwQAtMGw4ubYRiiwuiS2kNNL/YkGeJeZRGVt EyRidHxrl4cEfS4/HweWLB/0fd9GTJUHnanOCX5TDUG55hVRHAjDcM5m1M5cUw== X-Gm-Gg: ASbGncud2Rdjxz0Z3GJ5lUikUYM3+yWOb3wWtW33nq/ZdLev/b++cBJNVKml+z6LyDr RJCYMT5ziisFig7BoWKW3lTkeGH0OHV06rODTIisO4pGQdqWvGq9UCKKAgSolSM+5FHmlgIv3XK PCeQuvYWP+RkksAqDgO/k5vLMuJ5PL6TFGPpm6GSy1n6wBhI7zOUIR7MuiSpAfx8hGldbxmxcvL IqmHnKCE7XRRRV4wDrLC6TRCXkJ+DtoawleEl41dZ5eo+SGG46pJSx5X3K6Y34tO7oxIBjUSHkc PLTXdAqqInNXM8p8P9whIeWQlu5dV6mu+HUWZD/T6Pk+hekoKoTALeIgsCklQl6uxzmtKcGBsf9 DBGEx1/ZW5vpGpiNBEx9aZ5ttG8LD0SjPri5MlegJKJvfIBzcH9BQrhn62CoZIvBxvms4mw== X-Google-Smtp-Source: AGHT+IFPi7gIxZ312IihR0BEHZqG3LAeQiFrTEcfD8W7kchvKHfqe7J4hzosnVrXQvuMYNZRIIVyNQ== X-Received: by 2002:a05:6000:240a:b0:402:d5e6:2283 with SMTP id ffacd0b85a97d-425577f32e6mr1748556f8f.20.1759303728288; Wed, 01 Oct 2025 00:28:48 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e619a69besm25749925e9.12.2025.10.01.00.28.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Oct 2025 00:28:47 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: [PHP-DEV] [Discuss] Add PDO disconnect() and isConnected() In-Reply-To: Date: Wed, 1 Oct 2025 09:28:36 +0200 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: <241055E8-3365-4299-9B2F-4B94708CECFD@gmail.com> References: <4ddd9a25-47b8-4a2b-ad93-e93f8f33922b@app.fastmail.com> To: Larry Garfield X-Mailer: Apple Mail (2.3826.700.81) From: claude.pache@gmail.com (Claude Pache) > Le 30 sept. 2025 =C3=A0 23:07, Larry Garfield = a =C3=A9crit : >=20 > On Tue, Sep 30, 2025, at 3:08 PM, Claude Pache wrote: >>> Le 30 sept. 2025 =C3=A0 17:40, Larry Garfield = a =C3=A9crit : >>>=20 >>>=20 >>> What would be valuable is easier RE-connection logic. Either PHP or = MySQL may terminate an idle connection, which is a concern in = long-running processes (Queue workers, ReactPHP, Franken, etc.). Tools = like Doctrine have built their own refresh logic in, although they're = not always consistent with each other or obvious to use. Having some = kind of reconnection logic built into PDO that "just works" would be = very valuable. >>>=20 >>> What that would look like, I'm not sure. Just spitballing: >>>=20 >>> // After X seconds, drop and reopen the connection the next time = it's used. >>> $pdo->reconnectAfter($seconds); >>>=20 >>> --Larry Garfield >>=20 >> Auto-reconnection is dangerous, because database engines are = stateful.=20 >> For example, disaster will happen if disconnection had occurred in = the=20 >> middle of a transaction... >>=20 >> =E2=80=94Claude >=20 > All the more reason that the logic should be implemented once in PDO = and then shared, rather than everyone having to figure it out in user = space themselves. >=20 > I'm not suggesting that PDO actively try to disconnect all the time. = But if the connection is "stale," it should be able to restart it = without making the user faff about to do so. (Whether that's via = detecting that it's gone away, a timer, or whatever else, I'm very = flexible.) >=20 > --Larry Garfield Database connections are full of state (apart from transactions, there = are also sql variables, temporary tables, and probably other stuff I am = not aware of), thus auto-reconnection cannot be transparent in the = general case. In specific scenarios, this is ok, but I doubt that it is = best managed by a generic extension like pdo. =E2=80=94Claude=