Set num_shards in shared memory.

The get_num_shards() function, called from the WAL proposer, requires
it.

Fixes test_timeline_size_quota_on_startup
This commit is contained in:
Heikki Linnakangas
2025-07-31 16:29:24 +03:00
parent 9871a3f9e7
commit bb1f50bf09
3 changed files with 25 additions and 0 deletions

View File

@@ -134,6 +134,7 @@ communicator_new_bgworker_main(Datum main_arg)
connstrings = palloc(shard_map.num_shards * sizeof(char *));
for (int i = 0; i < shard_map.num_shards; i++)
connstrings[i] = shard_map.connstring[i];
AssignNumShards(shard_map.num_shards);
proc_handle = communicator_worker_process_launch(
cis,
neon_tenant,
@@ -232,6 +233,7 @@ communicator_new_bgworker_main(Datum main_arg)
for (int i = 0; i < shard_map.num_shards; i++)
connstrings[i] = shard_map.connstring[i];
AssignNumShards(shard_map.num_shards);
communicator_worker_config_reload(proc_handle,
file_cache_size,
connstrings,

View File

@@ -315,6 +315,27 @@ AssignShardMap(const char *newval)
}
}
/*
* Set the 'num_shards' variable in shared memory.
*
* This is only used with the new communicator. The new communicator doesn't
* use the shard_map in shared memory, except for the shard count, which is
* needed by get_num_shards() calls in the walproposer. This is called to set
* that. This is only called from the communicator process, at process startup
* or if the configuration is reloaded.
*/
void
AssignNumShards(shardno_t num_shards)
{
Assert(neon_use_communicator_worker);
pg_atomic_add_fetch_u64(&pagestore_shared->begin_update_counter, 1);
pg_write_barrier();
pagestore_shared->shard_map.num_shards = num_shards;
pg_write_barrier();
pg_atomic_add_fetch_u64(&pagestore_shared->end_update_counter, 1);
}
/* BEGIN_HADRON */
/**
* Return the total number of shards seen in the shard map.

View File

@@ -256,6 +256,8 @@ typedef struct
extern bool parse_shard_map(const char *connstr, ShardMap *result);
extern shardno_t get_shard_number(BufferTag* tag);
extern void AssignNumShards(shardno_t num_shards);
extern const f_smgr *smgr_neon(ProcNumber backend, NRelFileInfo rinfo);
extern void smgr_init_neon(void);
extern void readahead_buffer_resize(int newsize, void *extra);