diff --git a/pgxn/neon/communicator/src/worker_process/main_loop.rs b/pgxn/neon/communicator/src/worker_process/main_loop.rs index 0f20af6ba2..bca2c13fc4 100644 --- a/pgxn/neon/communicator/src/worker_process/main_loop.rs +++ b/pgxn/neon/communicator/src/worker_process/main_loop.rs @@ -53,11 +53,6 @@ pub struct CommunicatorWorkerProcessStruct<'a> { /// Local File Cache, relation size tracking, last-written LSN tracking pub(crate) cache: IntegratedCacheWriteAccess<'a>, - /*** Static configuration ***/ - /// Stripe size doesn't change after startup. (The shard map is not stored here, it's passed - /// directly to the client) - stripe_size: Option, - /*** Metrics ***/ pub(crate) lfc_metrics: LfcMetricsCollector, @@ -157,7 +152,6 @@ pub(super) fn init( // Note: it's important to not drop the runtime, or all the tasks are dropped // too. Including it in the returned struct is one way to keep it around. runtime, - stripe_size, neon_request_slots: cis.neon_request_slots, client, cache, @@ -199,10 +193,10 @@ impl<'t> CommunicatorWorkerProcessStruct<'t> { pub(super) fn update_shard_map( &self, new_shard_map: HashMap, + stripe_size: Option, ) { let client = self.client.as_ref().unwrap(); - let shard_spec = - ShardSpec::new(new_shard_map, self.stripe_size).expect("invalid shard spec"); + let shard_spec = ShardSpec::new(new_shard_map, stripe_size).expect("invalid shard spec"); { let _in_runtime = self.runtime.enter(); diff --git a/pgxn/neon/communicator/src/worker_process/worker_interface.rs b/pgxn/neon/communicator/src/worker_process/worker_interface.rs index c9c985c1b7..2d789a7e85 100644 --- a/pgxn/neon/communicator/src/worker_process/worker_interface.rs +++ b/pgxn/neon/communicator/src/worker_process/worker_interface.rs @@ -141,9 +141,11 @@ pub extern "C" fn communicator_worker_config_reload( file_cache_size: u64, shard_map: *mut *mut c_char, nshards: u32, + stripe_size: u32, ) { proc_handle.cache.resize_file_cache(file_cache_size as u32); let shard_map = shard_map_to_hash(nshards, shard_map); - proc_handle.update_shard_map(shard_map); + let stripe_size = (nshards > 1).then_some(ShardStripeSize(stripe_size)); + proc_handle.update_shard_map(shard_map, stripe_size); } diff --git a/pgxn/neon/communicator_process.c b/pgxn/neon/communicator_process.c index 36bd548f42..9f99087e53 100644 --- a/pgxn/neon/communicator_process.c +++ b/pgxn/neon/communicator_process.c @@ -224,7 +224,8 @@ communicator_new_bgworker_main(Datum main_arg) communicator_worker_config_reload(proc_handle, file_cache_size, connstrings, - shard_map.num_shards); + shard_map.num_shards, + neon_stripe_size); pfree(connstrings); }