Skip to content

Commit bf4fe17

Browse files
author
polyashov
committed
fix postgresql: measure rtt better
Tests: no commit_hash:37881ef48ae4c7952e896db8aafbc6e35577c9a2
1 parent 0935db1 commit bf4fe17

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

postgresql/src/storages/postgres/detail/topology/hot_standby.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,18 +315,17 @@ void HotStandby::RunCheck(DsnIndex idx) {
315315
}
316316
}
317317
auto deadline = GetTestsuiteControl().MakeExecuteDeadline(kCheckTimeout);
318-
auto start = std::chrono::steady_clock::now();
319318
try {
320319
state.connection->RefreshReplicaState(deadline);
321320
state.role = state.connection->IsInRecovery() ? ClusterHostType::kSlave : ClusterHostType::kMaster;
322321
state.is_readonly = state.connection->IsReadOnly();
323-
state.roundtrip_time = std::chrono::duration_cast<Rtt>(std::chrono::steady_clock::now() - start);
324-
325322
const auto& wal_info_stmts = GetWalInfoStatementsForVersion(state.connection->GetServerVersion());
326323
std::optional<std::chrono::system_clock::time_point> current_xact_timestamp;
327324

325+
auto start = std::chrono::steady_clock::now();
328326
const auto wal_info =
329327
state.connection->Execute(state.connection->IsInRecovery() ? wal_info_stmts.slave : wal_info_stmts.master);
328+
state.roundtrip_time = std::chrono::duration_cast<Rtt>(std::chrono::steady_clock::now() - start);
330329
wal_info.Front().To(state.wal_lsn, current_xact_timestamp);
331330
if (current_xact_timestamp) {
332331
state.current_xact_timestamp = *current_xact_timestamp;

0 commit comments

Comments
 (0)