Merge lp:~percona-toolkit-dev/percona-toolkit/pt-heartbeat-crashes-with-sleep-argument-1406390 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.14
Proposed by
Frank Cizmich
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Daniel Nichter | ||||
Approved revision: | 628 | ||||
Merged at revision: | 617 | ||||
Proposed branch: | lp:~percona-toolkit-dev/percona-toolkit/pt-heartbeat-crashes-with-sleep-argument-1406390 | ||||
Merge into: | lp:~percona-toolkit-dev/percona-toolkit/release-2.2.14 | ||||
Diff against target: |
42 lines (+12/-6) 1 file modified
bin/pt-heartbeat (+12/-6) |
||||
To merge this branch: | bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-heartbeat-crashes-with-sleep-argument-1406390 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Nichter | Approve | ||
Review via email: mp+254662@code.launchpad.net |
Description of the change
Problem:
pt-heartbeat was reported to fail sometimes when using --sleep option
Although unable to reproduce the code clearly showed a potential race condition where:
1) time function was tested to be over a certain fixed interval
2) a loop was entered waiting for next interval
3) on exiting the loop a sleep is issued with a potentially negative value due to the clock ticks transpiring after the exit of the loop
Solution:
Save the time value in a variable and use that value in the code to guarantee a positive value for the sleep function
To post a comment you must log in.
Code comments are always helpful for the next person, e.g. in case someone runs into this code and wonders why the time is being saved in another var. Can also mention the bug/jira issue URL. Otherwise, code is fine.