PragmaTwice commented on code in PR #3047:
URL: https://github.com/apache/kvrocks/pull/3047#discussion_r2203762382
##########
src/server/server.cc:
##########
@@ -700,6 +701,63 @@ void Server::OnEntryAddedToStream(const std::string &ns,
const std::string &key,
}
}
+void Server::BlockOnWait(redis::Connection *conn, rocksdb::SequenceNumber
target_seq, uint64_t num_replicas) {
+ std::lock_guard<std::mutex> guard(wait_contexts_mu_);
+
+ wait_contexts_.emplace_back(conn, target_seq, num_replicas);
+ IncrBlockedClientNum();
+}
+
+void Server::WakeupWaitConnections(rocksdb::SequenceNumber seq) {
+ std::lock_guard<std::mutex> guard(wait_contexts_mu_);
+
+ for (auto it = wait_contexts_.begin(); it != wait_contexts_.end();) {
+ // Check if target sequence is reached
+ if (seq >= it->target_seq) {
+ // Count how many replicas have reached the target sequence
+ int reached_replicas = GetReplicasReachedSequence(it->target_seq);
+
+ // If enough replicas have reached the target sequence, wake up the
connection
+ if (reached_replicas >= static_cast<int>(it->num_replicas)) {
Review Comment:
```suggestion
size_t reached_replicas = GetReplicasReachedSequence(it->target_seq);
// If enough replicas have reached the target sequence, wake up the
connection
if (reached_replicas >= it->num_replicas) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]