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 1tjicS-00CmKN-Es for pgsql-hackers@arkaria.postgresql.org; Sun, 16 Feb 2025 17:39:52 +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 1tjicR-009kVl-6a for pgsql-hackers@arkaria.postgresql.org; Sun, 16 Feb 2025 17:39:51 +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 1tjicQ-009kVd-TJ for pgsql-hackers@lists.postgresql.org; Sun, 16 Feb 2025 17:39:50 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tjicO-001C88-1N for pgsql-hackers@postgresql.org; Sun, 16 Feb 2025 17:39:50 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-220d132f16dso52363065ad.0 for ; Sun, 16 Feb 2025 09:39:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1739727586; x=1740332386; 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=jrJ8fZOyKmanAnUQVUfN31dven/lRwatKuq+INR9xvE=; b=S2lX7Pd7Urmnuz7pirgRTBO6Ls+vUOrdSkSjVVCKqmqGin1W7AFCQ9Od8uQd+3QRvX iKZjkB7LXBLVg+9M8m32X/XOBV+o7l55Z4iOeQiT+8Bri6hvpgHGM14DyyMaG9xhTxsT /zg7FXEtDTaa8et5YdqXFFRq0afqQESDd3DhY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739727586; x=1740332386; 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=jrJ8fZOyKmanAnUQVUfN31dven/lRwatKuq+INR9xvE=; b=I0AztRTLDQpf30HffWs2xMSuuJbEsNdQ8ZMTXayqrMTlpkJ/yLmWratliSJrWb1ING /RmxnRMIzE4x7OmkCOAqPa+wAzQ1FIrO7km03AXWUHurNRp8cfoU+eycAc5Sbkm/uJp/ WuVzYcGWko5NBaVxl9q1NvnbZCte4Dvrmms9Jy/tY2F5/0kej33hIcj/e7j0LO6fXtDN ygvswzsnM1+M3+BEuBFk33cRGAWKYoT1cgbsovKr35h43vQdeKo+K4GEvAB/CZhKE5T1 jVSwIJseyTFa6N2aiLqj/xxmZ81L/AK0xNVSOKbpeWb+UKcJLeWqJW/rUoKuobaZi0lp 4HAA== X-Gm-Message-State: AOJu0YxEv08/A/fKVGdPfS+BtFgSBF91t17J70JtFj8WqsQ33oYbfGUN Oaq1U4QrGfa0kMRpqK0FRfyz8XloR+1+NUM9cV4b1fIKm0/BdvctVRb+HmlpUEmQmIPX2NhUbPo = X-Gm-Gg: ASbGnct+fGIEtHyRYbDHHhkMPB06PXsijCLo2on7+uczPfCN1S5CWDDBpzWQTpPqqwb M3zD5rdW6W9J2hBE994aukSNgAuc+fmFt2UJU7z8VIsMhVhq/M9LNVKGK8PQlDu5CVAbSNvGNdm 8/OFsOij8yYuN007cc0ZZn5C7Sary1jNnAAgBYq+znGyGKOy3XkbLC0lcXmTROMDxKK+4fma8LX z27F0+XzvbKINeY0fVT8tGDqfNZfqCVaco2qHMfEwGgOXg8yu0djjYGIGed2N681r+hFf3xN1jY ckLKAiwaew== X-Google-Smtp-Source: AGHT+IHV7DPiRP+RTeLvma1OLXD7GC4q4Y/noWubsTxH58OHEAnItVEly3jtvg8TnF8wDCZ6/TN2Bg== X-Received: by 2002:a05:6a20:258d:b0:1ee:5ed3:6c20 with SMTP id adf61e73a8af0-1ee8cb1ddb5mr13383905637.25.1739727586118; Sun, 16 Feb 2025 09:39:46 -0800 (PST) Received: from google.com ([2600:1702:a20:5750::46]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73258dece33sm4144206b3a.37.2025.02.16.09.39.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Feb 2025 09:39:45 -0800 (PST) Date: Sun, 16 Feb 2025 09:39:43 -0800 From: Noah Misch To: Andres Freund Cc: pgsql-hackers@postgresql.org Subject: Re: BackgroundPsql swallowing errors on windows Message-ID: <20250216173943.b6.nmisch@google.com> References: 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 Thu, Feb 13, 2025 at 12:39:04PM -0500, Andres Freund wrote: > My understanding is that IPC::Run uses a proxy process on windows to execute > subprocesses and then communicates with that over TCP (or something along > those lines). Right. > 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? > The banner being the same between queries made it hard to understand if a > banner that appeared in the output was from the current query or a past > query. Therefore I added a counter to it. Sounds good. > For debugging I added a "note" that shows stdout/stderr after executing the > query, I think it may be worth keeping that, but I'm not sure. It should be okay to keep. We're not likely to funnel huge amounts of data through BackgroundPsql. If we ever do that, we could just skip the "note" for payloads larger than some threshold. v2 of the patch looks fine.