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 1rA7cv-004tMy-Od for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Dec 2023 12:00:41 +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 1rA7cu-00GSxw-7V for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Dec 2023 12:00:40 +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 1rA7ct-00GSxo-Tf for pgsql-hackers@lists.postgresql.org; Mon, 04 Dec 2023 12:00:39 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rA7cl-00A2nB-LA for pgsql-hackers@lists.postgresql.org; Mon, 04 Dec 2023 12:00:38 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a1b75f59a12so95688866b.3 for ; Mon, 04 Dec 2023 04:00:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1701691228; x=1702296028; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=yhQTkZWf83EGk+m8w4tx3ScPlSG/DEal8LjYYaNrag8=; b=XAGmEG+/sVVfJDelihnx8bg16VRMik5sQ+DGKG3FC7CTAzHuy3ssUtFIq3t8uf4i6P mbWbRqyuheay+Cs/KhwSOo5er/bgK7Umgh7mCgIJcgISPb1ygV1cItiutI7a0nefV9sH wLeQ8frRoUjiGi5Nyj8EW8m9bBqboaic1cUbNPbdAYmyKULBjUI4KjLIkQ1dFSJ0/3Ig F/F6RlMlO/xrAKT1JZKWI238faQ5wKQbmTNnV1XwRjdQIRmhA/l5GjFAAc3ZZ4YDPb1k rOeTfs45pQSY7UHrG8WyoKPa7d3bXy01kZbVuWCUk0kzonBznTTA+QB4GX2b57KVBN2S Hs1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701691228; x=1702296028; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yhQTkZWf83EGk+m8w4tx3ScPlSG/DEal8LjYYaNrag8=; b=GrY1OivbFBKoUudIL6iBfQmxfwcxRxgD1czpW6RXomlYaeq5AtQ7/D11OpJotlKP+N AZwU2Wg2Xax20R5iIvKKOU5RYeLbf67k/LF6GMq2/UT41IZaPFaCkwiNtqki259THKer yBouADGM8+vX01bxI513ASL/4TJ6Vjv5ncTvETJIfW0ziv86ebdZ39JpOvuPPXnOv/aT WbX3FUZn3YVsvmTT+ZmImYDMriXZQLk8GMFH53pdh84QwfCXE03EOWZccvRMEq1IWozu 2ixX4jFlPgJyDagS/j5mpHpNNlSLTsyctTZ9O/ZIkwwODqvOUkCQ2kLvScTkkLodbW91 cHew== X-Gm-Message-State: AOJu0Yx15ItrdVgsWwWrswx3vx7VRQkSIP/2OhjaGUgq22MQCzfaU2mT ilAWdl6Dq9kq24g+qppJXn3dRg== X-Google-Smtp-Source: AGHT+IGRNdPhPrgrCRPvaFsYT0qKDx3XgfCSQrgR6lJc+yRwUWYbAphd00qmgQnBzl+TqEyFcZqdkw== X-Received: by 2002:a17:907:584:b0:a19:d40a:d223 with SMTP id vw4-20020a170907058400b00a19d40ad223mr1358842ejb.239.1701691228412; Mon, 04 Dec 2023 04:00:28 -0800 (PST) Received: from [10.137.0.17] (srv1.mobissw.com. [89.235.0.226]) by smtp.gmail.com with ESMTPSA id r23-20020a170906365700b00a177e311e09sm5170882ejb.70.2023.12.04.04.00.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Dec 2023 04:00:28 -0800 (PST) Message-ID: Date: Mon, 4 Dec 2023 13:00:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: undetected deadlock in ALTER SUBSCRIPTION ... REFRESH PUBLICATION To: Amit Kapila , Shlok Kyal Cc: PostgreSQL Hackers References: <8948e4a2-fec7-8a61-9ace-2537cee3ef6f@enterprisedb.com> <69e9a1af-a315-8b05-0674-2cc53bf27682@enterprisedb.com> <9afab261-94a7-3e58-f0fb-040e45f42aa5@enterprisedb.com> Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/4/23 12:37, Amit Kapila wrote: > On Sat, Dec 2, 2023 at 9:52 PM Shlok Kyal wrote: >> >>> thread. I think you can compare the timing of regression tests in >>> subscription, with and without the patch to show there is no >>> regression. And probably some tests with a large number of tables for >>> sync with very little data. >> >> I have tested the regression test timings for subscription with and >> without patch. I also did the timing test for sync of subscription >> with the publisher for 100 and 1000 tables respectively. >> I have attached the test script and results of the timing test are as follows: >> >> Time taken for test to run in Linux VM >> Summary | Subscription Test (sec) >> | 100 tables in pub and Sub (sec) | 1000 tables in pub and Sub >> (sec) >> Without patch Release | 95.564 >> | 7.877 | 58.919 >> With patch Release | 96.513 >> | 6.533 | 45.807 >> >> Time Taken for test to run in another Linux VM >> Summary | Subscription Test (sec) >> | 100 tables in pub and Sub (sec) | 1000 tables in pub and Sub >> (sec) >> Without patch Release | 109.8145 >> | 6.4675 | 83.001 >> With patch Release | 113.162 >> | 7.947 | 87.113 >> > > So, on some machines, it may increase the test timing although not too > much. I think the reason is probably doing the work in multiple > transactions for multiple relations. I am wondering that instead of > committing and starting a new transaction before > wait_for_relation_state_change(), what if we do it inside that > function just before we decide to wait? It is quite possible that in > many cases we don't need any wait at all. > I'm not sure what you mean by "do it". What should the function do? As for the test results, I very much doubt the differences are not caused simply by random timing variations, or something like that. And I don't understand what "Performance Machine Linux" is, considering those timings are slower than the other two machines. Also, even if it was a bit slower, does it really matter? I mean, the current code is wrong, can lead to infinite duration if it happens to hit the deadlock. And it's a one-time action, I don't think it's a very sensitive in terms of performance. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company