Skip to content

Conversation

vyavdoshenko
Copy link
Contributor

fixes: #4884

Fixed overflow on calculating time difference.

if (!input_str.empty())
break;
RETURN_ON_ERR(Recv(sock_.get(), io_buf));
TouchIoTime();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also factor out the lines 260-269 into the Recv call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But there is a call of TouchIoTime() at 268. This looks correct.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it is correct but there is code duplication -you can replace these lines with Recv and TouchIoTime calls like we do here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@vyavdoshenko vyavdoshenko self-assigned this Apr 6, 2025
@vyavdoshenko vyavdoshenko requested a review from romange April 7, 2025 12:04
res.master_last_io_sec = (ProactorBase::GetMonotonicTimeNs() - last_io_time) / 1000000000UL;

uint64_t current_time = ProactorBase::GetMonotonicTimeNs();
// Handle the case when last_io_time is greater than current time
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets change the comment to this:
// last_io_time is derived above by reading last_io_time_ from all the flows, by accessing them from a foreign thread, see the loop above. As a result some threads may have last_io_time_ bigger than our current time, so we fix it here.

This way you explain why this happens, not just what you do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

VLOG(2) << "Read master response of " << *size_res << " bytes";
ec = Recv(sock_.get(), buffer);
if (ec) {
LOG(WARNING) << "Socket error " << ec;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you already do this inside Recv()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


TouchIoTime();
buffer->CommitWrite(*size_res);
VLOG(3) << "Read master response";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this vlog is not helpful now and can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

romange
romange previously approved these changes Apr 9, 2025
Copy link
Collaborator

@romange romange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with small nits

@vyavdoshenko vyavdoshenko enabled auto-merge (squash) April 9, 2025 13:45
@vyavdoshenko vyavdoshenko merged commit b1f8c9b into main Apr 9, 2025
10 checks passed
@vyavdoshenko vyavdoshenko deleted the bobik/invalid-master_last_io_seconds_ago-metric branch April 9, 2025 14:25
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.

invalid master_last_io_seconds_ago metric during stable sync
3 participants