Skip to content

Commit

Permalink
memory-trim: Fix timestamp overflow warning right after reboot.
Browse files Browse the repository at this point in the history
If OVN is started less than 30 seconds after system boot, it logs:

  |memory_trim|WARN|Detected last active timestamp overflow

The 'now < trim_timeout_ms' is not for a timestamp overflow, but
for the later subtraction.  'now < last_active_ms' is enough to
check for the overflow.

Technically, we shouldn't need to check that now > trim_timeout_ms
before subtraction, because the result should be a signed integer,
but it's cleaner this way.

Fixes: 12ddb1c ("lflow-cache: Automatically trim cache when it becomes inactive.")
Signed-off-by: Ilya Maximets <[email protected]>
Signed-off-by: Dumitru Ceara <[email protected]>
(cherry picked from commit 11cd04a)
  • Loading branch information
igsilya authored and dceara committed Oct 10, 2023
1 parent 8f7003d commit ba8db43
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions controller/lflow-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,21 +332,15 @@ lflow_cache_run(struct lflow_cache *lc)
}

long long int now = time_msec();
if (now < lc->last_active_ms || now < lc->trim_timeout_ms) {
if (now < lc->last_active_ms) {
VLOG_WARN_RL(&rl, "Detected cache last active timestamp overflow");
lc->recently_active = false;
lflow_cache_trim__(lc, true);
return;
}

if (now < lc->trim_timeout_ms) {
VLOG_WARN_RL(&rl, "Detected very large trim timeout: "
"now %lld ms timeout %"PRIu32" ms",
now, lc->trim_timeout_ms);
return;
}

if (now - lc->trim_timeout_ms >= lc->last_active_ms) {
if (now > lc->trim_timeout_ms
&& now - lc->trim_timeout_ms >= lc->last_active_ms) {
VLOG_INFO_RL(&rl, "Detected cache inactivity "
"(last active %lld ms ago): trimming cache",
now - lc->last_active_ms);
Expand Down

0 comments on commit ba8db43

Please sign in to comment.