MCPcopy Create free account
hub / github.com/apache/kvrocks / WakeupWaitConnections

Method WakeupWaitConnections

src/server/server.cc:747–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

745}
746
747void Server::WakeupWaitConnections(rocksdb::SequenceNumber seq) {
748 std::unique_lock<std::shared_mutex> guard(wait_contexts_mu_);
749
750 // find the last entry with target_seq > seq, which cannot wakeup
751 auto end_it = wait_contexts_.upper_bound(seq);
752 for (auto it = wait_contexts_.begin(); it != end_it;) {
753 // Count how many replicas have reached the target sequence
754 size_t reached_replicas = GetReplicasReachedSequence(it->second.target_seq);
755
756 // If enough replicas have reached the target sequence, wake up the connection
757 if (reached_replicas >= it->second.num_replicas) {
758 // Send the response with the number of replicas that have reached the target sequence
759 it->second.conn->Reply(redis::Integer(reached_replicas));
760
761 auto s = it->second.conn->Owner()->EnableWriteEvent(it->second.conn->GetFD());
762 if (!s.IsOK()) {
763 ERROR("[server] Failed to enable write event on WAIT connection {}: {}", it->second.conn->GetFD(), s.Msg());
764 }
765 it = wait_contexts_.erase(it);
766 DecrBlockedClientNum();
767 continue;
768 }
769 ++it;
770 }
771}
772
773void Server::WakeupWaitConnection(redis::Connection *conn, rocksdb::SequenceNumber seq) {
774 std::unique_lock<std::shared_mutex> guard(wait_contexts_mu_);

Callers 1

readCallbackMethod · 0.80

Calls 8

beginMethod · 0.80
EnableWriteEventMethod · 0.80
OwnerMethod · 0.80
GetFDMethod · 0.80
IntegerFunction · 0.70
ReplyMethod · 0.45
IsOKMethod · 0.45
MsgMethod · 0.45

Tested by

no test coverage detected