Skip to content

Init etcd client#2

Open
eskedesu wants to merge 42 commits intodevelopfrom
init_etcd_client
Open

Init etcd client#2
eskedesu wants to merge 42 commits intodevelopfrom
init_etcd_client

Conversation

@eskedesu
Copy link
Owner


Note: by creating a PR or an issue you automatically agree to the CLA. See CONTRIBUTING.md. Feel free to remove this note, the agreement holds.

eskedesu pushed a commit that referenced this pull request Jun 19, 2025
…lanceScheduler

`~SubscribeSentinel()` calls `storage_->Stop();` that calls `rebalance_scheduler_.reset()`; after that `~SubscribeSentinel()` resets the `Sentinel::impl_`.

After `rebalance_scheduler_.reset()` but before `Sentinel::impl_.reset()` a `topology_holder_` may gen a notification that calls `sentinel_obj_.Notify*` that calls `rebalance_scheduler_->Rebalance*`:

```
#0 0x7f4fbe737fc4 in __pthread_mutex_lock
#1 0xd928c8 in __libcpp_mutex_lock
#2 0xd928c8 in std::__y1::mutex::lock()
#3 0x224289b in lock_guard
userver-framework#4 0x224289b in storages::redis::impl::SubscriptionRebalanceScheduler::RequestRebalance(std::__y1::unordered_map<storages::redis::ServerId, unsigned long, storages::redis::ServerIdHasher, std::__y1::equal_to<storages::redis::ServerId>, std::__y1::allocator<std::__y1::pair<storages::redis::ServerId const, unsigned long>>>) /userver/redis/src/storages/redis/impl/subscription_rebalance_scheduler.cpp:37:43
userver-framework#5 0x22369e9 in storages::redis::impl::ClusterSubscriptionStorage::RequestRebalance(unsigned long, std::__y1::unordered_map<storages::redis::ServerId, unsigned long, storages::redis::ServerIdHasher, std::__y1::equal_to<storages::redis::ServerId>, std::__y1::allocator<std::__y1::pair<storages::redis::ServerId const, unsigned long>>>) /userver/redis/src/storages/redis/impl/cluster_subscription_storage.cpp:139:27
userver-framework#6 0x223019f in storages::redis::impl::SubscribeSentinel::RebalanceSubscriptions(unsigned long) /userver/redis/src/storages/redis/impl/subscribe_sentinel.cpp:171:15
userver-framework#7 0x2193ccd in operator() /userver/redis/src/storages/redis/impl/cluster_sentinel_impl.cpp:885:27
userver-framework#8 0x2193ccd in boost::detail::function::void_function_obj_invoker<storages::redis::impl::ClusterSentinelImpl::Init()::$_0, void, std::__y1::basic_string<char, std::__y1::char_traits<char>, std::__y1::allocator<char>>, storages::redis::RedisState>::invoke(boost::detail::function::function_buffer&, std::__y1::basic_string<char, std::__y1::char_traits<char>, std::__y1::allocator<char>>, storages::redis::RedisState)
```

We must call Stop() instead of reset.

`ClusterSentinelImpl::Stop()` does a blocking `ev_thread_.Run*`, so all the signal callbacks finish execution before destruction.

Tests: протестировано локально и в CI
commit_hash:c731ae2859d6acde9605e2c526cd9ac20f15e4e8
eskedesu pushed a commit that referenced this pull request Jun 19, 2025
…lanceScheduler

`~SubscribeSentinel()` calls `storage_->Stop();` that calls `rebalance_scheduler_.reset()`; after that `~SubscribeSentinel()` resets the `Sentinel::impl_`.

After `rebalance_scheduler_.reset()` but before `Sentinel::impl_.reset()` a `topology_holder_` may gen a notification that calls `sentinel_obj_.Notify*` that calls `rebalance_scheduler_->Rebalance*`:

```
#0 0x7f4fbe737fc4 in __pthread_mutex_lock
#1 0xd928c8 in __libcpp_mutex_lock
#2 0xd928c8 in std::__y1::mutex::lock()
#3 0x224289b in lock_guard
userver-framework#4 0x224289b in storages::redis::impl::SubscriptionRebalanceScheduler::RequestRebalance(std::__y1::unordered_map<storages::redis::ServerId, unsigned long, storages::redis::ServerIdHasher, std::__y1::equal_to<storages::redis::ServerId>, std::__y1::allocator<std::__y1::pair<storages::redis::ServerId const, unsigned long>>>) /userver/redis/src/storages/redis/impl/subscription_rebalance_scheduler.cpp:37:43
userver-framework#5 0x22369e9 in storages::redis::impl::ClusterSubscriptionStorage::RequestRebalance(unsigned long, std::__y1::unordered_map<storages::redis::ServerId, unsigned long, storages::redis::ServerIdHasher, std::__y1::equal_to<storages::redis::ServerId>, std::__y1::allocator<std::__y1::pair<storages::redis::ServerId const, unsigned long>>>) /userver/redis/src/storages/redis/impl/cluster_subscription_storage.cpp:139:27
userver-framework#6 0x223019f in storages::redis::impl::SubscribeSentinel::RebalanceSubscriptions(unsigned long) /userver/redis/src/storages/redis/impl/subscribe_sentinel.cpp:171:15
userver-framework#7 0x2193ccd in operator() /userver/redis/src/storages/redis/impl/cluster_sentinel_impl.cpp:885:27
userver-framework#8 0x2193ccd in boost::detail::function::void_function_obj_invoker<storages::redis::impl::ClusterSentinelImpl::Init()::$_0, void, std::__y1::basic_string<char, std::__y1::char_traits<char>, std::__y1::allocator<char>>, storages::redis::RedisState>::invoke(boost::detail::function::function_buffer&, std::__y1::basic_string<char, std::__y1::char_traits<char>, std::__y1::allocator<char>>, storages::redis::RedisState)
```

We must call Stop() instead of reset.

`ClusterSentinelImpl::Stop()` does a blocking `ev_thread_.Run*`, so all the signal callbacks finish execution before destruction.

Tests: протестировано локально и в CI
commit_hash:c731ae2859d6acde9605e2c526cd9ac20f15e4e8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant