PSMDB-1960 Fix flaky TimeoutSetAndGetAreConsistent test#1693
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Updates an Asio socket timeout round-trip unit test to avoid Linux-kernel-dependent rounding behavior (pre-5.1 jiffies-based storage) that was making the test flaky across common HZ configurations.
Changes:
- Adjust
TimeoutSetAndGetAreConsistentto use a timeout value that round-trips exactly across common LinuxHZvalues. - Add inline documentation explaining the kernel/jiffies rounding behavior and rationale for the chosen duration.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| timeoutOptionTest([](auto& socket, auto option, const char* name) { | ||
| using Option = decltype(option); | ||
| const auto duration = std::chrono::milliseconds(42); | ||
| // Use a duration that is an exact multiple of 20ms (the LCM of jiffie sizes for |
There was a problem hiding this comment.
Typo in the comment: the correct term is “jiffy” (singular) / “jiffies” (plural), not “jiffie”.
Suggested change
| // Use a duration that is an exact multiple of 20ms (the LCM of jiffie sizes for | |
| // Use a duration that is an exact multiple of 20ms (the LCM of jiffy sizes for |
On Linux kernels prior to 5.1, SO_RCVTIMEO/SO_SNDTIMEO are stored internally as jiffies using ceiling division. The previous test value of 42ms is not exactly representable in jiffies for HZ=250 (rounds to 44ms) or HZ=100 (rounds to 50ms), causing the ASSERT_EQ to fail on machines with those kernel configurations. Changed to 100ms, which is an exact multiple of 20ms (the LCM of jiffy sizes for HZ=100, 250, and 1000), ensuring the set/get round-trip is exact on all common kernel HZ values.
plebioda
approved these changes
Feb 20, 2026
ktrushin
approved these changes
Feb 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Linux kernels prior to 5.1, SO_RCVTIMEO/SO_SNDTIMEO are stored internally as jiffies using ceiling division. The previous test value of 42ms is not exactly representable in jiffies for HZ=250 (rounds to 44ms) or HZ=100 (rounds to 50ms), causing the ASSERT_EQ to fail on machines with those kernel configurations. Changed to 100ms, which is an exact multiple of 20ms (the LCM of jiffy sizes for HZ=100, 250, and 1000), ensuring the set/get round-trip is exact on all common kernel HZ values.