MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / SyncData

Method SyncData

src/replica/replicate_node.cc:117–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117void ReplicateNode::SyncData() {
118 uint32_t coffee_time = 0;
119 while (is_running_.load(std::memory_order_relaxed)) {
120 if (coffee_time > 0) {
121 bthread_usleep(coffee_time * 1000);
122 coffee_time = 0;
123 }
124 {
125 std::unique_lock<bthread::Mutex> lock(*mu_);
126 // no new data append and wait
127 while (last_sync_offset_ >=
128 leader_log_offset_->load(std::memory_order_relaxed)) {
129 cv_->wait_for(lock, FLAGS_binlog_sync_wait_time * 1000);
130 if (!is_running_.load(std::memory_order_relaxed)) {
131 PDLOG(INFO,
132 "replicate log to endpoint %s for table #tid %u #pid "
133 "%u exist",
134 endpoint_.c_str(), tid_, pid_);
135 return;
136 }
137 }
138 }
139 int ret;
140 if (rep_node_.load(std::memory_order_relaxed)) {
141 ret = SyncData(follower_offset_->load(std::memory_order_relaxed));
142 } else {
143 ret = SyncData(leader_log_offset_->load(std::memory_order_relaxed));
144 }
145 if (ret == 1) {
146 coffee_time = FLAGS_binlog_coffee_time;
147 }
148 }
149 PDLOG(INFO, "replicate log to endpoint %s for table #tid %u #pid %u exist",
150 endpoint_.c_str(), tid_, pid_);
151}
152
153int ReplicateNode::GetLogIndex() { return log_reader_.GetLogIndex(); }
154

Callers 1

RunSyncTaskFunction · 0.80

Calls 13

DebugStringFunction · 0.85
clearMethod · 0.80
ReadNextRecordMethod · 0.80
okMethod · 0.80
GoBackToStartMethod · 0.80
GoBackToLastBlockMethod · 0.80
IsWaitRecordMethod · 0.80
IsInvalidRecordMethod · 0.80
SendRequestMethod · 0.80
codeMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected