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 1reJwa-00AieU-As for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Feb 2024 19:13:48 +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 1reJwY-008bBq-J6 for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Feb 2024 19:13:47 +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 1reJwY-008bBh-0y for pgsql-hackers@lists.postgresql.org; Sun, 25 Feb 2024 19:13:46 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1reJwP-000xZt-6N for pgsql-hackers@postgresql.org; Sun, 25 Feb 2024 19:13:44 +0000 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5648d92919dso3004567a12.1 for ; Sun, 25 Feb 2024 11:13:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1708888415; x=1709493215; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=aYhP/6L5jZfNE/+okK+e3y4B7w9FCtuh5x8UCvWZqAY=; b=JLN2FSd8B6ZzBd/hLFNJj1WaopirajZqq1gwu3H0TOFuC9aH56yBnEMpCcZfjOHXvq CqgWcffj6w8BtWqBDtiD8U0t2hU5ZmRcOAcbFMIousTrSdUzNTVMzaCtqthWkdJogfbR WPvIysKhxVvDzq1LvojxLJiP3I+6hSwVmKk4jGzKUyLJMbxgmasJtRGWGrC2niwTbdXV nmLcH8cLjRJK/Voplh5/rSqXCm7B457m5gLVkMvI08gvuaso/xPIGZXt3A8qukpwC0YX f2UGogkQ6qBCd+juWYQHZPj2VBwNLOcVt4HDpzznyHtTVV0F1z7qJLod9MpI3aCVek7l aK8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708888415; x=1709493215; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aYhP/6L5jZfNE/+okK+e3y4B7w9FCtuh5x8UCvWZqAY=; b=uQ6M+Sk0KDvYQUAlgN1Hb0YWAehmMB5e+w9m4ix7J/bSQCkEJteIyxXnNnxHKnao1d avxihEWSfYYc5LsSW+f/r7D349UTtYOiXFkLGculEFrW8YbQz7pb01XyPNPcREcZenK5 HGEqHjgaaG+ivmDM+cJhoRU3FklFQJ7tOn5yo2Reek4CvEJ4Fcz+/kLFPzMXx6Tl9/RD PZzg4WwiDvteYitxN2pqD4nLcY80W/KnjxovLl2mdVTOeE6PQ3VCte8j9N50resAbQKH oq3/docV6VCc4l/usdXRooesvl7iXqf+GEEWNHaoqqBJ7MrF6JdPxJsJK3nybvdP7r2x vFIQ== X-Forwarded-Encrypted: i=1; AJvYcCU1zZa7liFWijdRdE0cOMaAjbnowed5l3mx2ZD3ZP8cM2V1LH0dfXhED8kmCExY75epR3F6ihsCJlS/pxf0BIv+WUEfs7hA+mrc11MA X-Gm-Message-State: AOJu0YwuAW1kKo7oFIMXyG5KZSOqrdI/00CtY3S/cWxFq8xZN+jUiiLw sh5jfxvtrHbvfftYdjh68KCnHPbl9o+H2m0bhRiWh7H8qm/F8ECszFEWWWbiyw== X-Google-Smtp-Source: AGHT+IGyH3R3RcX57W/2lk9KnTkaB3rbQOthIiytlnkdKuU7Xj3F8cNkAvuQ4b0Il84xMTZGr7zDvA== X-Received: by 2002:aa7:d748:0:b0:565:d63a:708d with SMTP id a8-20020aa7d748000000b00565d63a708dmr987660eds.14.1708888415381; Sun, 25 Feb 2024 11:13:35 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id z18-20020aa7c652000000b005657eefa8e9sm1618567edr.4.2024.02.25.11.13.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Feb 2024 11:13:34 -0800 (PST) Message-ID: <0d08b978-10cb-4512-bcef-ca1f192049ab@enterprisedb.com> Date: Sun, 25 Feb 2024 20:13:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Logging parallel worker draught Content-Language: en-US To: "Imseih (AWS), Sami" , =?UTF-8?Q?Benoit_Lobr=C3=A9au?= , Alvaro Herrera Cc: Robert Haas , Amit Kapila , pgsql-hackers , Melanie Plageman References: <10D5C31A-A303-4440-BCA2-921440A9E1CC@amazon.com> <202310111011.lyo66rk7k7pu@alvherre.pgsql> <9E9E69BD-BABB-49BB-8B69-61939179F20D@amazon.com> <11e34b80-b0a6-e2e4-1606-1f5077379a34@dalibo.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, I see the thread went a bit quiet, but I think it'd be very useful (and desirable) to have this information in log. So let me share my thoughts about the patch / how it should work. The patch is pretty straightforward, I don't have any comments about the code as is. Obviously, some of the following comments might require changes to the patch, etc. I see there was discussion about logging vs. adding this to the pgstats system. I agree with Alvaro it should not be one or the other - these are complementary approaches, used by different tools. The logging is needed for tools like pgbadger etc. for example. I do see a lot of value in adding this to the statistics collector, and to things like pg_stat_statements, but that's being discussed in a separate thread, so I'll comment on that there. As for whether to have a GUC for this, I certainly think we should have one. We have GUC for logging stuff that we generally expect to happen, like lock waits, temp files, etc. True, there are similar cases that we just log every time, like when we can't fork a process ("could not fork autovacuum launcher process"), but I'd say those are unexpected to happen in general / seem more like an error in the environment. While we may exhaust parallel workers pretty easily / often, especially on busy systems. There's a couple things I'm not quite sure about: 1) name of the GUC I find the "log_parallel_worker_draught" to be rather unclear :-( Maybe it's just me and everyone else just immediately understands what this does / what will happen after it's set to "on", but I find it rather non-intuitive. 2) logging just the failures provides an incomplete view As a DBA trying to evaluate if I need to bump up the number of workers, I'd be interested what fraction of parallel workers fails to start. If it's 1%, that's probably a short spike and I don't need to do anything. If it's 50%, well, that might have unpredictable impact on user queries, and thus something I may need to look into. But if we only log the failures, that's not possible. I may be able to approximate this somehow by correlating this with the query/transaction rate, or something, but ideally I'd like to know how many parallel workers we planned to use, and how many actually started. Obviously, logging this for every Gather [Merge] node, even when all the workers start, that may be a lot of data. Perhaps the GUC should not be on/off, but something like log_parallel_workers = {none | failures | all} where "failures" only logs when at least one worker fails to start, and "all" logs everything. AFAIK Sami made the same observation/argument in his last message [1]. 3) node-level or query-level? There's a brief discussion about whether this should be a node-level or query-level thing in [2]: > I wonder if it will be better to accumulate the total # of workers > planned and # of workers launched and logging this information at the > end of execution? And there's a reference to log_temp_files, but it's not clear to me if that's meant to be an argument for doing it the same way (node-level). I think we should not do node-level logging just because that's what log_temp_files=on dies. I personally think log_temp_files was implemented like this mostly because it was simple. There's no value in having information about every individual temp file, because we don't even know which node produced it. It'd be perfectly sufficient to log some summary statistics (number of files, total space, ...), either for the query as a whole, or perhaps per node (because that's what matters for work_mem). So I don't think we should mimic this just because log_temp_files does this. I don't know how difficult would it be to track/collect this information for the whole query. regards [1] https://www.postgresql.org/message-id/D04977E3-9F54-452C-A4C4-CDA67F392BD1%40amazon.com [2] https://www.postgresql.org/message-id/11e34b80-b0a6-e2e4-1606-1f5077379a34%40dalibo.com -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company