Merge lp:~vlad-lesin/percona-playback/bug-1021577 into lp:percona-playback

Proposed by Vlad Lesin on 2012-07-09
Status: Merged
Approved by: Stewart Smith on 2012-07-10
Approved revision: 145
Merged at revision: 148
Proposed branch: lp:~vlad-lesin/percona-playback/bug-1021577
Merge into: lp:percona-playback
Diff against target: 77 lines (+28/-10)
1 file modified
percona_playback/tcpdump/tcpdump_query_entries.cc (+28/-10)
To merge this branch: bzr merge lp:~vlad-lesin/percona-playback/bug-1021577
Reviewer Review Type Date Requested Status
Stewart Smith (community) 2012-07-09 Approve on 2012-07-10
Review via email: mp+113963@code.launchpad.net

Description of the change

Fix for bug #1021577

To post a comment you must log in.
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'percona_playback/tcpdump/tcpdump_query_entries.cc'
2--- percona_playback/tcpdump/tcpdump_query_entries.cc 2012-06-19 15:26:53 +0000
3+++ percona_playback/tcpdump/tcpdump_query_entries.cc 2012-07-09 12:10:26 +0000
4@@ -28,8 +28,8 @@
5 TcpdumpQueryEntry::execute(DBThread *t)
6 {
7 QueryResult expected_result;
8- boost::posix_time::ptime start_time;
9- boost::posix_time::ptime end_time;
10+ timeval start_time;
11+ timeval end_time;
12 boost::shared_ptr<DBThreadState> thr_state;
13
14 assert(t);
15@@ -71,13 +71,16 @@
16
17 last_query_info.result.clear();
18
19- start_time= boost::posix_time::microsec_clock::universal_time();
20+ gettimeofday(&start_time, NULL);
21 t->execute_query(query, &last_query_info.result, expected_result);
22- end_time= boost::posix_time::microsec_clock::universal_time();
23+ gettimeofday(&end_time, NULL);
24
25- boost::posix_time::time_period duration(start_time, end_time);
26- last_query_info.result.setDuration(duration.length());
27+ last_query_info.result.setDuration(
28+ boost::posix_time::microseconds(
29+ end_time.tv_sec*1000000 + end_time.tv_usec -
30+ start_time.tv_sec*1000000 - start_time.tv_usec));
31 last_query_info.begin_pcap_timestamp= pcap_timestamp;
32+ last_query_info.end_timestamp= end_time;
33 last_query_info.query= query;
34 }
35
36@@ -85,10 +88,14 @@
37 TcpdumpResultEntry::execute(DBThread *t)
38 {
39 timeval query_execution_time;
40+ timeval current_time;
41+ timeval tv_btw_query_end_and_result_start;
42+ boost::posix_time::time_duration total_duration;
43+
44 boost::shared_ptr<DBThreadState> thr_state;
45-
46+
47 assert(t);
48-
49+
50 thr_state= t->get_state();
51
52 assert(thr_state.get());
53@@ -106,11 +113,22 @@
54 query_execution_time.tv_usec +
55 query_execution_time.tv_sec*1000000));
56
57+ gettimeofday(&current_time, NULL);
58+ timersub(&current_time,
59+ &last_query_info.end_timestamp,
60+ &tv_btw_query_end_and_result_start);
61+
62+ total_duration=
63+ last_query_info.result.getDuration() +
64+ boost::posix_time::microseconds(
65+ tv_btw_query_end_and_result_start.tv_sec*1000000 +
66+ tv_btw_query_end_and_result_start.tv_usec);
67+
68 if (g_tcpdump_mode == TCPDUMP_MODE_ACCURATE &&
69- (expected_result.getDuration() > last_query_info.result.getDuration()))
70+ (expected_result.getDuration() > total_duration))
71 {
72 boost::posix_time::time_duration us_sleep_time=
73- expected_result.getDuration() - last_query_info.result.getDuration();
74+ expected_result.getDuration() - total_duration;
75
76 usleep(us_sleep_time.total_microseconds());
77 }

Subscribers

People subscribed via source and target branches

to all changes: