Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121904 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 27774 invoked from network); 2 Dec 2023 10:35:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Dec 2023 10:35:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B055E18002B for ; Sat, 2 Dec 2023 02:35:39 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (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 ; Sat, 2 Dec 2023 02:35:39 -0800 (PST) Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-425427286a8so4732781cf.3 for ; Sat, 02 Dec 2023 02:35:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=youmind.jp; s=google; t=1701513328; x=1702118128; darn=lists.php.net; 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=hMQJnctx+7nelwggU6OxLzgEgG66xUr1SzApGEcrfJY=; b=LljfY47XNW5k9PHV3Wd65EBlfiTbDO37NjHqi2AbakcHwUWWuYhiLq+GVUeGMtI50Y vfqN2bd0ENtozpGzcRGTqt42YkWFXkHDHqub7YevzQhPfkpjuY1kmLPTeIZENUOih5u3 E5fF1JWdlPQOhpaQ5hqYLCj6cDGeCn62AnQB3aQhfR8meNgPFPApWTgJRW51HVuFv38v DonlIhxQnkZtBlZvrovWu4LIOBEMcZaQa01BTZberQPtOf5+ymiFqNXhvCJcjy1g5+4n JozLIwdx1XaACM5ssC75EvsbSldMr5jafFF8V0lKyHzkmPL74okGtcv68HipG12QjbUr 5Tfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701513328; x=1702118128; 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=hMQJnctx+7nelwggU6OxLzgEgG66xUr1SzApGEcrfJY=; b=G48TQkQ95q5R2LoIC6zTgk/MyI7hqycHMacNkrSzayOezJlMaRLZmqd10QOMeSh1nT DSa3ij++zYO5rRcNMiPw2hX5NIuwG29RpUY1vpSgr3h+sc1mxnIrvJbz0bzSB7ZhYy6m Fl6QWDhSPQytdhv+yKzxLPk/hANMCOKmSQuD+hN4li3lRavRf7XdSFu6uJXlowhpWHyb RycL1Ivu60GPVUfrzeFacvsnEyMHSoSFPbc5XPPfOM9J1InJXt9uJIsfaUcwtGf0DPpc pPdLs2fQW/ptHv+g9RfQquGtjF8Rznoo083hu+xaMhw0d9ho7VBgr9DC844QuOZwObnw Y7ag== X-Gm-Message-State: AOJu0Yy2ZvICMskmS5V15TXwmPKi9AjEBEVHL4EshfzcijgwniSNlDwg hU8i41QAK/mS9o285KSNsmOsoWH10YieY9Jqw2IrPg== X-Google-Smtp-Source: AGHT+IH2IkgS3tyzt4SJLQ7Ej0FDMI1Spw2YANICHywt8kKLHV2mq9LOcGbEc67Y7c4HKzt6yljj3Rfod6q5yVozZcQ= X-Received: by 2002:ac8:5951:0:b0:425:4043:96db with SMTP id 17-20020ac85951000000b00425404396dbmr1416390qtz.104.1701513328563; Sat, 02 Dec 2023 02:35:28 -0800 (PST) MIME-Version: 1.0 References: <6A2118D9-6DD0-4273-A2C0-A1088C05314D@sakiot.com> <6cfba3c2-c754-422f-8031-0f6046f828ac@app.fastmail.com> In-Reply-To: Reply-To: Kentaro Takeda Date: Sat, 2 Dec 2023 19:35:17 +0900 Message-ID: To: Eugene Sidelnyk Cc: Deleu , Bruce Weirdan , php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [PDO] 2 phase commit From: internals@lists.php.net ("Kentaro Takeda via internals") Hi Eugene. > 1. We have sent commit to the first database and it responded us with OK = (comitted) > 2. Next we send commit to the second database, and it may be the case tha= t in that very moment we lose connection. Hence, if connection is lost befo= re final commit request, second database won't receive commit, and since It= 's not aware of whether transaction should be committed or rolled back, dat= a is never made persistent. > > FWIK, this case is usually handled at the application level using async c= ommit in message consumers. Meaning commit operation will be retied again, = and again, and again until the connection is restored. > > Therefore, commit point is the point of no-return and network issues is t= he problem we have to deal with. This point highlights a critical and common challenge in deciding whether to commit to a database. Moreover, this consideration applies broadly to any side effects on external systems, not solely to databases or two-phase commits. Since the solution method differs depending on the system requirements and specifications, I think developers should ensure safety through their own implementation, and in other words, there is no need to consider it as a capability of PHP itself. Consider, for instance more generally, the following scenarios where unintended loss of connectivity and processing interruptions are critical. * Send multiple HTTP requests with side-effects to external APIs at the same time. If the connection is lost before the response is returned. * Processes that acquire locks, such as by creating a file in the filesystem, rather than using locks from RDBMS, Redis, etc. If the process is terminated abnormally by the OS while locked, it becomes difficult to determine if the file's presence is due to an unfinished process or an abnormal termination. In both scenarios, consistency will be checked using another process equivalent to the message consumers you mentioned, or some other method. In the case of a two-phase commit as well, I think that PHP itself MAY do nothing (or SHOULD NOT do anything). Regarts. Kentaro Takeda