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 1pKOFW-0006LK-Of for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jan 2023 18:42:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pKOFV-0006Yo-Kd for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jan 2023 18:42:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKOFV-0006Yf-8r for pgsql-hackers@lists.postgresql.org; Tue, 24 Jan 2023 18:42:25 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pKOFS-0001SY-0m for pgsql-hackers@postgresql.org; Tue, 24 Jan 2023 18:42:24 +0000 Received: by mail-pg1-x533.google.com with SMTP id 78so11887062pgb.8 for ; Tue, 24 Jan 2023 10:42:21 -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=XE3iLJaw3yilmLU5B3d9MV+vrJ9NUrh2YAW+d0jlZPM=; b=o8GJ/bHB64Hs+F/c3ZG4jNk4vtp8MUTYeM0Xi/ipSVn995mwdlMuEVvxQdEYSpHoRj vOJWjubQoo+Eg27o4HH0Khs6FSf5FhEETOldiBrb0c0fRDFAVxKCtrQJXbTs+frNPUfl 7hsXsxwZfRv0+fzzS9p/fWyoTCY/e7mUQSs8ZXT10JrGhqx+C+JVIa87+9eliKAxqMMF bE7ZkkUVvSPk2o2MBrme9NeryhODo1S5MsIVuPDvbys0fvKiJGdG1KiHcmoasSpkjLYH /zsBGs1LFx38sAPxS46or+yKsXneV5TDOAUP9a5rBhkmb5Ca+sOkIdUM28qJPPa1O44q l5wg== 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=XE3iLJaw3yilmLU5B3d9MV+vrJ9NUrh2YAW+d0jlZPM=; b=UZMn+6QipzFhFGsGqOtSE10FwU50hkufTBUJgkPfuXEUeXwPt8sV9sFPKvJCzpSemE CHkTSEmPOytAOIm2YCJyMcq5G43AK6h2E+DVExjhdfrLFj9TkjQ2GgVpJZLxdzyGmsqF yZxUotsBJ2pS+3oSY8c/YACXHh2jft7DLsdjAffqf1h3kKP2LgWXR4u6PVglmZGDqPra HGsUwgM7TT7Yng5jE6LGlhqkVAzTsrr3BOr9fEuRl6f3H5LPqbX4lO3xCKkgYvceTxIf u/jRyhneKmSq04rdrMUvmfJznEAX1pH1yJgQwxZi4bwVQ31BIW1w/9cK3EY1tU4djHej n7wg== X-Gm-Message-State: AFqh2kq9STXfCEd9dwGeXgPvobp50tfvTfqmdoG3omrbiWvm1wzdFg3R 4YjSdeeawfO+of38miWF3og= X-Google-Smtp-Source: AMrXdXttfiEWTQBtEx+6MSy1t6TxvNukv35h8S/limXV2y3VN5pP7kZfobd6bmgmjiLDfDAQxDN//A== X-Received: by 2002:a62:1d56:0:b0:58d:9251:b2a6 with SMTP id d83-20020a621d56000000b0058d9251b2a6mr38255474pfd.1.1674585739704; Tue, 24 Jan 2023 10:42:19 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id y5-20020a056a00180500b0058d97b624f0sm1928013pfa.75.2023.01.24.10.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 10:42:18 -0800 (PST) Date: Tue, 24 Jan 2023 10:42:17 -0800 From: Nathan Bossart To: Tom Lane Cc: "houzj.fnst@fujitsu.com" , Amit Kapila , Melih Mutlu , Thomas Munro , "Hayato Kuroda (Fujitsu)" , "pgsql-hackers@postgresql.org" Subject: Re: wake up logical workers after ALTER SUBSCRIPTION Message-ID: <20230124184217.GA724858@nathanxps13> References: <20230106054017.GA786807@nathanxps13> <3355444.1673044286@sss.pgh.pa.us> <20230107004525.GB789289@nathanxps13> <20230110174345.GA1292607@nathanxps13> <1353772.1674414774@sss.pgh.pa.us> <20230124171329.GA677220@nathanxps13> <2268133.1674584035@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="lrZ03NoBR/3+SXJZ" Content-Disposition: inline In-Reply-To: <2268133.1674584035@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jan 24, 2023 at 01:13:55PM -0500, Tom Lane wrote: > Either that comment needs to be rewritten or we need to invent some > more macros. Here is a first attempt at a patch. I scanned through all the existing uses of InvalidDsaPointer and DSM_HANDLE_INVALID and didn't notice anything else that needed adjusting. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --lrZ03NoBR/3+SXJZ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="invalid_handle_values.patch" diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index 564bffe5ca..970d170e73 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -922,8 +922,8 @@ ApplyLauncherShmemInit(void) memset(LogicalRepCtx, 0, ApplyLauncherShmemSize()); - LogicalRepCtx->last_start_dsa = DSM_HANDLE_INVALID; - LogicalRepCtx->last_start_dsh = DSM_HANDLE_INVALID; + LogicalRepCtx->last_start_dsa = DSA_HANDLE_INVALID; + LogicalRepCtx->last_start_dsh = DSHASH_HANDLE_INVALID; /* Initialize memory and spin locks for each worker slot. */ for (slot = 0; slot < max_logical_replication_workers; slot++) @@ -947,7 +947,7 @@ logicalrep_launcher_attach_dshmem(void) MemoryContext oldcontext; /* Quick exit if we already did this. */ - if (LogicalRepCtx->last_start_dsh != DSM_HANDLE_INVALID && + if (LogicalRepCtx->last_start_dsh != DSHASH_HANDLE_INVALID && last_start_times != NULL) return; @@ -957,7 +957,7 @@ logicalrep_launcher_attach_dshmem(void) /* Be sure any local memory allocated by DSA routines is persistent. */ oldcontext = MemoryContextSwitchTo(TopMemoryContext); - if (LogicalRepCtx->last_start_dsh == DSM_HANDLE_INVALID) + if (LogicalRepCtx->last_start_dsh == DSHASH_HANDLE_INVALID) { /* Initialize dynamic shared hash table for last-start times. */ last_start_times_dsa = dsa_create(LWTRANCHE_LAUNCHER_DSA); diff --git a/src/include/lib/dshash.h b/src/include/lib/dshash.h index 152927742e..c284c8489c 100644 --- a/src/include/lib/dshash.h +++ b/src/include/lib/dshash.h @@ -23,6 +23,9 @@ typedef struct dshash_table dshash_table; /* A handle for a dshash_table which can be shared with other processes. */ typedef dsa_pointer dshash_table_handle; +/* Special value for an unitinitialized dshash_table_handle */ +#define DSHASH_HANDLE_INVALID ((dshash_table_handle) InvalidDsaPointer) + /* The type for hash values. */ typedef uint32 dshash_hash; diff --git a/src/include/utils/dsa.h b/src/include/utils/dsa.h index 104386e674..ee59a76447 100644 --- a/src/include/utils/dsa.h +++ b/src/include/utils/dsa.h @@ -99,6 +99,9 @@ typedef pg_atomic_uint64 dsa_pointer_atomic; */ typedef dsm_handle dsa_handle; +/* Special value for an unitinitialized dsa_handle */ +#define DSA_HANDLE_INVALID ((dsa_handle) DSM_HANDLE_INVALID) + extern dsa_area *dsa_create(int tranche_id); extern dsa_area *dsa_create_in_place(void *place, size_t size, int tranche_id, dsm_segment *segment); --lrZ03NoBR/3+SXJZ--