Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2fVr-0000bg-Ty for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Dec 2022 21:30:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p2fVp-0003UC-Ls for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Dec 2022 21:30:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2fVo-0003Ts-Un for pgsql-hackers@lists.postgresql.org; Tue, 06 Dec 2022 21:30:01 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p2fVm-0001lZ-1y for pgsql-hackers@postgresql.org; Tue, 06 Dec 2022 21:29:59 +0000 Received: by mail-pj1-x102a.google.com with SMTP id z8-20020a17090abd8800b00219ed30ce47so5027453pjr.3 for ; Tue, 06 Dec 2022 13:29:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=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=5lU/Xli87+sqc4EdCitz5PuVm51x4g0ZaFOlbtfDZoY=; b=oBR9Ykgs1CLAw8p/B79M7ohIWHYJHgZud3TNu8vM+SRuCsEhhAXcAfzpM61IScHkeZ bM2pvKRtdONaNkoFT2ouumQzp7ELOJYaddnD8zSnKGTX6QUYGPFOn3X8YGcYl2KwucQQ VA7sGbWxJODwA2KwWpGJQLcDY2m/dXt5i3Q7DOxu8pqTpvhlEW+t2usfjfxIZyX9Pbvh DIbV8ef1erzG4rZOAPa3dDoUTHBuuXBpbxqmkjCmQ6N+4qrXWQMEAW9q9n/AkyA9hr4K Bwnnmav86LEbsKS9satOyWzjWWkYNJjVhoUmcpvHdWoe3uR8/O+2+/aDO9r1hQYqYabV 04Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=5lU/Xli87+sqc4EdCitz5PuVm51x4g0ZaFOlbtfDZoY=; b=UPO9dW4oken8xebuBFdcyiuPYXvQT111Fkpdf2Hh11MAt7zeWNAdz8kPBkFwdP4v85 i9W5dcnfdrePiSejpRjgo5/cbg26ryHDG7hurkH/DcoqekMBL08AdLWeFA1EDONzo3iD 7qpPBV0GJxMtN2jn990X6QACnJZQnpy07SDIm5ze0CXvi9jIZzhHfgGKh5sCR+exXag7 6DBiXYL/zzECoz8QKj06oJxpb7ioEYOhF1BnJ1bnidqq7HgfPWA3JOId4rgojFU+Npo3 yqeMmgxmnPMV8z8GRWfoWKb4ia7Gwz96qxZpGij0MsYjpqb5Q3X5ZgYM5kqmyDYQFbEs mrIg== X-Gm-Message-State: ANoB5pnQ2ucHCpqFhvTb2ks3qHH0+zS1Oney17pjGhprJfTlOmoookpM 8PlkOfnKN5k8tGndACa/t+Q= X-Google-Smtp-Source: AA0mqf4FYs6xdHWFfGXrrr+lR1EXFW5lFJuyDtnozfHECsRylCtH7x1q9abnr1P9Y+lJXMyngViJFQ== X-Received: by 2002:a17:902:cecd:b0:189:c72b:986f with SMTP id d13-20020a170902cecd00b00189c72b986fmr17551876plg.98.1670362196880; Tue, 06 Dec 2022 13:29:56 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id i28-20020a056a00005c00b005771f5ea2ebsm3217969pfk.135.2022.12.06.13.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 13:29:56 -0800 (PST) Date: Tue, 6 Dec 2022 13:29:54 -0800 From: Nathan Bossart To: Melih Mutlu Cc: Thomas Munro , "Hayato Kuroda (Fujitsu)" , "pgsql-hackers@postgresql.org" Subject: Re: wake up logical workers after ALTER SUBSCRIPTION Message-ID: <20221206212954.GA3403597@nathanxps13> References: <20221127234528.GB878043@nathanxps13> <20221130041028.GA1604177@nathanxps13> <20221130050441.GA1677223@nathanxps13> <20221202002130.GA2124877@nathanxps13> <20221202192101.GB2277157@nathanxps13> <20221206192551.GA3078082@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J2SCkAp4GZ/dPZZf" Content-Disposition: inline In-Reply-To: <20221206192551.GA3078082@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --J2SCkAp4GZ/dPZZf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Dec 06, 2022 at 11:25:51AM -0800, Nathan Bossart wrote: > On Tue, Dec 06, 2022 at 07:44:46PM +0300, Melih Mutlu wrote: >> - When the state is SYNCDONE and the apply worker has to wake up to change >> the state to READY. >> >> I think we already call logicalrep_worker_wakeup_ptr wherever it's needed >> for the above cases? What am I missing here? > > IIUC we must restart all the apply workers for a subscription to enable > two_phase mode. It looks like finish_sync_worker() only wakes up its own > apply worker. I moved this logic to where the sync worker marks the state > as SYNCDONE and added a check that two_phase mode is pending. Even so, > there can still be unnecessary wakeups, but this adjustment should limit > them. Actually, that's not quite right. The sync worker will wake up the apply worker to change the state from SYNCDONE to READY. AllTablesyncsReady() checks that all tables are READY, so we need to wake up all the workers when an apply worker changes the state to READY. Each worker will then evaluate whether to restart for two_phase mode. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --J2SCkAp4GZ/dPZZf Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v7-0001-wake-up-logical-workers-as-needed-instead-of-rely.patch"