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 1tjjgD-00CweQ-Au for pgsql-hackers@arkaria.postgresql.org; Sun, 16 Feb 2025 18:47:49 +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 1tjjgA-00A9Nc-N6 for pgsql-hackers@arkaria.postgresql.org; Sun, 16 Feb 2025 18:47:46 +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 1tjjgA-00A9NU-9M for pgsql-hackers@lists.postgresql.org; Sun, 16 Feb 2025 18:47:46 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tjjg7-001AiH-39 for pgsql-hackers@postgresql.org; Sun, 16 Feb 2025 18:47:44 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2fc292b3570so3940053a91.1 for ; Sun, 16 Feb 2025 10:47:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1739731662; x=1740336462; darn=postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=9XqZ5/HPP7bbQuHGC8U71pvRCY1IZuCiWeIePB0KLi8=; b=AOdXRI/ViDEkkuWmz4GaJ3l/uS0m+wX5cRVlgI3Qd6T7S6pA++68l8PFJ+oIGHUfbg 3Wie5SgR2T+GESfAYJrBpgWTarPhRjaRIkJSkzlGs8lzVPxxz1Hm1yzo6FIQDQO32GKA b3GbfnaYQcLSTv4mz1F9NdEoHp9jBGEj41hrQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739731662; x=1740336462; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9XqZ5/HPP7bbQuHGC8U71pvRCY1IZuCiWeIePB0KLi8=; b=THMgsjBZSMsf2DIHPt4qfPln9Qw91THVGIYkXvG1shZtMVxIIqGMiq8e8TLl5ClgDZ FU8Lu2+1gvbXdZh3QsMd1NTIoP+X9XXmkzciEdmnT6YkgxHV63aoGedudQINk4XuAbqu WhyhJiF2lwgB98hWyIb3qp72CxfQtP6y9vhJmnxZZSNV9uH9+HtYi0jpy5HJzshlhKOM QF5/gLzJ1NrAqN+I8E6iNtNGs4CTrloF6joT/ZpHxRkkS0+JQWGY19+d5bkIEpBwyQgK Zvnhim/X323LBDVe4EpsPJQ2yhb7JDe25ZzAtlxJTuJrknthImnj/B5yXDna3SfDB6Iq PoTw== X-Gm-Message-State: AOJu0Yx2/jV1beE0todelKpA7ysUes/ICOAQBozzafN3QSxdu5Yv4Q3l /HyAXzIMg0M1/T6o6a0UIVFe9Ysm2L2NafPxtyeT4OmDB+ixhjQZJ6pyPQ9H8NkRXc51PyW9Iwc = X-Gm-Gg: ASbGncvq20D9jmkNMLPIw7MPk3CJiNpnqOOMBXrjyMSnMc1ZBAD3diAWCk0Wv6eZJ/2 A3jBFO6L+If4e3aas1Zxx3XlU38rVkQgQY7GYI2aJxBXX6VhLt4qn55TOIavPuQj8n6yxkkhxvx KdysIdFgSflhV41arrW3eEDvSabbI8BEuEgzPa5OlPrHuc0FwPLEaKWy3MadkvxdWKG6c/lHRKW VAL1LWTD0NSdg/tsz5Dq+GkQz154kRfG5WCO631D8wupFKutEJPs1gR5RXsNcV6yS4+U+gTO8AJ ICwLCHrZ0g== X-Google-Smtp-Source: AGHT+IH61yysmJfhxX+gIOr+fXHPqPh1xzruTV55oDzct6z43mvHddu8A2Yrt04EOqxgYvquhfAReA== X-Received: by 2002:a17:90b:2252:b0:2ee:c9b6:c26a with SMTP id 98e67ed59e1d1-2fc40f1086amr10929544a91.11.1739731662296; Sun, 16 Feb 2025 10:47:42 -0800 (PST) Received: from google.com ([2600:1702:a20:5750::46]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13b91424sm6524904a91.31.2025.02.16.10.47.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Feb 2025 10:47:41 -0800 (PST) Date: Sun, 16 Feb 2025 10:47:40 -0800 From: Noah Misch To: Andres Freund Cc: pgsql-hackers@postgresql.org Subject: Re: BackgroundPsql swallowing errors on windows Message-ID: <20250216184740.55.nmisch@google.com> References: <20250216173943.b6.nmisch@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Feb 16, 2025 at 01:02:01PM -0500, Andres Freund wrote: > On 2025-02-16 09:39:43 -0800, Noah Misch wrote: > > On Thu, Feb 13, 2025 at 12:39:04PM -0500, Andres Freund wrote: > > > I suspect what's happening is that the communication with the > > > external process allows for reordering between stdout/stderr. > > > > > > And indeed, changing BackgroundPsql::query() to emit the banner on both stdout > > > and stderr and waiting on both seems to fix the issue. > > > > That makes sense. I wondered how one might fix IPC::Run to preserve the > > relative timing of stdout and stderr, not perturbing the timing the way that > > disrupted your test run. I can think of two strategies: > > > > - Remove the proxy. > > > > - Make pipe data visible to Perl variables only when at least one of the > > proxy<-program_under_test pipes had no data ready to read. In other words, > > if both pipes have data ready, make all that data visible to Perl code > > simultaneously. (When both the stdout pipe and the stderr pipe have data > > ready, one can't determine data arrival order.) > > > > Is there a possibly-less-invasive change that might work? > > I don't really know enough about IPC::Run's internals to answer. My > interpretation of how it might work, purely from observation, is that it opens > one tcp connection for each "pipe" and that that's what's introducing the > potential of reordering, as the different sockets can have different delivery > timeframes. Right. > If that's it, it seems proxying all the pipes through one > connection might be an option. It would. Thanks. However, I think that would entail modifying the program under test to cooperate with the arrangement. When running an ordinary program that does write(1, ...) and write(2, ...), the read end needs some way to deal with the uncertainty about which write happened first. dup2(1, 2) solves the order ambiguity, but it loses other signal. > I did briefly look at IPC::Run's code, but couldn't figure out how it all fits > together quickly enough... We can ignore what IPC::Run does today. The reordering is a general problem of proxying >1 pipe. (Proxying on non-Windows would have the same problem.)