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 1rXL3X-00A6Tb-N6 for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Feb 2024 13:00:08 +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 1rXL3W-004IQL-Me for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Feb 2024 13:00:06 +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 1rXL3W-004IQD-DV for pgsql-hackers@lists.postgresql.org; Tue, 06 Feb 2024 13:00:06 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rXL3U-005lfB-Ah for pgsql-hackers@postgresql.org; Tue, 06 Feb 2024 13:00:05 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-51142b5b76dso4700084e87.2 for ; Tue, 06 Feb 2024 05:00:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707224403; x=1707829203; 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=kj6f0AlLti4Ws857vnrGaFaAg8/he2aMpki/MTzafYw=; b=nh8Tqtph3e5K/G+N81B/MndLsRVyoePm2osq/2cTPWQyr2F4wmZh5EYB6NyMay7WSA dVKN7stmJybJedDTBzbkEQwL01UAOXYo3e+vjl1fyBLQ+mISwmTbC3YKPIV8mf9/dEWC ZFAlXxTSqZGIcg/Gjr5tSgTX0F9h9ALmfcz0i4EIcrNn+AxkbmcinJEtCCQagXo4EcIB BtE/2oX2L4K1ZVmQTlw3R3H8M8ZySdCH3Qphb9L/V3lNjgqGwg1eW/V6uVh/CGF9zPFp V7Yg+H7a7uIM6L4QR52SZsdedHXCZVwibyj+kX5IY5JsD1RZ+JQpSJLrrbRSOavdzxaX 4ylQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707224403; x=1707829203; 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=kj6f0AlLti4Ws857vnrGaFaAg8/he2aMpki/MTzafYw=; b=OhiPIce7dQS9pIUrldCoEwJDMEzaAOgl/QJvz5CWEpLLOp1zsJi6ky/ki+trktPLuS vcCYHoL9B100BvvbuTVJslkkZgam2taf6CrabbVjSaKFn15ZOzL7KcfCPtiCFL/jt330 6D1z68+SgdqV1r5hoHe11s71xXutFv9gAS0+KNelegJBKI9wB3WAjbWJzfxdwmzzcY5C dBMub7gilNvCPUUE+XbvKJm89i1AaPpnIjkCCANQYYEd9TwZ3N0pE6XAw9UqncdMjcsf pDMVSQLtmSo0LwgZW3cr6w9l0UYG5ZDmNkQSfDRiiQfIZKGHh6DzQuA4jlCwA7w0yavu tjxQ== X-Gm-Message-State: AOJu0Yysispl9VeLUlHRGXzRoFcR8DCDOgg8Nt2ht+dKSstRE8cHeyCs WzKVwlxWN7iyHNr/MBH/Ggg+AY9+GyKWp3qfozdY5tr4YFflVxALTNqiq9vSrLs= X-Google-Smtp-Source: AGHT+IESqqo7yjOil7CvsBq++v4eqizhG13E1WplY7Cq0CIM0t0qdvvrrH5SZYkF9i0gfK4p8JBngg== X-Received: by 2002:ac2:446d:0:b0:511:49ce:afc1 with SMTP id y13-20020ac2446d000000b0051149ceafc1mr1582813lfl.48.1707224403265; Tue, 06 Feb 2024 05:00:03 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWY6//rPKbHGnnDJ8cd+tHRo+3CsHiev3Skr87zmwc++0kFj86b2ylmSOWmqYpS8oBAYOs1i7HrZ7g1NLbXkmTwW0rfirrvBq+VkIKc Received: from [1.0.0.7] ([178.155.31.74]) by smtp.gmail.com with ESMTPSA id d12-20020ac2544c000000b005114292eadesm235608lfn.295.2024.02.06.05.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Feb 2024 05:00:02 -0800 (PST) Message-ID: Date: Tue, 6 Feb 2024 16:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: Race condition in FetchTableStates() breaks synchronization of subscription tables Content-Language: en-US To: vignesh C Cc: "Zhijie Hou (Fujitsu)" , pgsql-hackers References: <711a6afe-edb7-1211-cc27-1bef8239eec7@gmail.com> <858a7622-2c81-1687-d1df-1322dfcb2e72@gmail.com> From: Alexander Lakhin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 05.02.2024 13:13, vignesh C wrote: > Thanks for the steps for the issue, I was able to reproduce this issue > in my environment with the steps provided. The attached patch has a > proposed fix where the latch will not be set in case of the apply > worker exiting immediately after starting. It looks like the proposed fix doesn't help when ApplyLauncherWakeup() called by a backend executing CREATE SUBSCRIPTION command. That is, with the v4-0002 patch applied and pg_usleep(300000L); added just below             if (!worker_in_use)                 return worker_in_use; I still observe the test 027_nosuperuser running for 3+ minutes: t/027_nosuperuser.pl .. ok All tests successful. Files=1, Tests=19, 187 wallclock secs ( 0.01 usr  0.00 sys +  4.82 cusr  4.47 csys =  9.30 CPU) IIUC, it's because a launcher wakeup call, sent by "CREATE SUBSCRIPTION regression_sub ...", gets missed when launcher waits for start of another worker (logical replication worker for subscription "admin_sub"), launched just before that command. Best regards, Alexander