{"action":"opened","issue":{"url":"https://api.github.com/repos/cockroachdb/cockroach/issues/3234","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/3234/labels{/name}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/3234/comments","events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/3234/events","html_url":"https://github.com/cockroachdb/cockroach/issues/3234","id":119125871,"number":3234,"title":"ms.IntentAge is negative number","user":{"login":"changrui82","id":15647248,"avatar_url":"https://avatars.githubusercontent.com/u/15647248?v=3","gravatar_id":"","url":"https://api.github.com/users/changrui82","html_url":"https://github.com/changrui82","followers_url":"https://api.github.com/users/changrui82/followers","following_url":"https://api.github.com/users/changrui82/following{/other_user}","gists_url":"https://api.github.com/users/changrui82/gists{/gist_id}","starred_url":"https://api.github.com/users/changrui82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/changrui82/subscriptions","organizations_url":"https://api.github.com/users/changrui82/orgs","repos_url":"https://api.github.com/users/changrui82/repos","events_url":"https://api.github.com/users/changrui82/events{/privacy}","received_events_url":"https://api.github.com/users/changrui82/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-27T03:26:54Z","updated_at":"2015-11-27T03:26:54Z","closed_at":null,"body":"In `MergeMVCCStats` function, we have:\r\n```\r\n\tdiffSeconds := nowNanos/1E9 - rs.LastUpdateNanos/1E9\r\n\tms.LastUpdateNanos = nowNanos\r\n\tms.IntentAge += rs.IntentCount * diffSeconds\r\n\tms.GCBytesAge += engine.MVCCComputeGCBytesAge(rs.KeyBytes+rs.ValBytes-rs.LiveBytes, diffSeconds)\r\n\trs.MVCCStats.Add(ms)\r\n```\r\nAnd in `rs.MVCCStats.Add(ms)` we have:\r\n```\r\n...\r\n\tif oms.LastUpdateNanos > ms.LastUpdateNanos {\r\n\t\tms.LastUpdateNanos = oms.LastUpdateNanos\r\n\t}\r\n```\r\nSo, when update `ms.LastUpdateNanos`, we check whether `oms.LastUpdateNanos` greater than `ms.LastUpdateNanos`. But when calculate `diffSeconds`, we don't make any check. (`rs.LastUpdateNanos` and `ms.LastUpdateNanos` in `rs.MVCCStats.Add(ms)` is the same variable)\r\nAs a result, I often see minus `diffSeconds` in my test, then ms.IntentAge will be minus(can be smaller than -10000 in busy range, because `rs.IntentCount * diffSeconds` will amplify minus diffSeconds again and again).\r\n\r\nI'm not sure whether it is a problem, because after a long time, it can turn to positive number based on `elapsedSeconds`. But if I want to make intent GC start in a short time rather than very long time(24 hours currently), it will be a obstacle."}}