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
=== modified file 'percona_playback/tcpdump/tcpdump_query_entries.cc'
--- percona_playback/tcpdump/tcpdump_query_entries.cc 2012-06-19 15:26:53 +0000
+++ percona_playback/tcpdump/tcpdump_query_entries.cc 2012-07-09 12:10:26 +0000
@@ -28,8 +28,8 @@
28TcpdumpQueryEntry::execute(DBThread *t)28TcpdumpQueryEntry::execute(DBThread *t)
29{29{
30 QueryResult expected_result;30 QueryResult expected_result;
31 boost::posix_time::ptime start_time;31 timeval start_time;
32 boost::posix_time::ptime end_time;32 timeval end_time;
33 boost::shared_ptr<DBThreadState> thr_state;33 boost::shared_ptr<DBThreadState> thr_state;
3434
35 assert(t);35 assert(t);
@@ -71,13 +71,16 @@
7171
72 last_query_info.result.clear();72 last_query_info.result.clear();
7373
74 start_time= boost::posix_time::microsec_clock::universal_time();74 gettimeofday(&start_time, NULL);
75 t->execute_query(query, &last_query_info.result, expected_result);75 t->execute_query(query, &last_query_info.result, expected_result);
76 end_time= boost::posix_time::microsec_clock::universal_time();76 gettimeofday(&end_time, NULL);
7777
78 boost::posix_time::time_period duration(start_time, end_time);78 last_query_info.result.setDuration(
79 last_query_info.result.setDuration(duration.length());79 boost::posix_time::microseconds(
80 end_time.tv_sec*1000000 + end_time.tv_usec -
81 start_time.tv_sec*1000000 - start_time.tv_usec));
80 last_query_info.begin_pcap_timestamp= pcap_timestamp;82 last_query_info.begin_pcap_timestamp= pcap_timestamp;
83 last_query_info.end_timestamp= end_time;
81 last_query_info.query= query;84 last_query_info.query= query;
82}85}
8386
@@ -85,10 +88,14 @@
85TcpdumpResultEntry::execute(DBThread *t)88TcpdumpResultEntry::execute(DBThread *t)
86{89{
87 timeval query_execution_time;90 timeval query_execution_time;
91 timeval current_time;
92 timeval tv_btw_query_end_and_result_start;
93 boost::posix_time::time_duration total_duration;
94
88 boost::shared_ptr<DBThreadState> thr_state;95 boost::shared_ptr<DBThreadState> thr_state;
89 96
90 assert(t);97 assert(t);
91 98
92 thr_state= t->get_state();99 thr_state= t->get_state();
93100
94 assert(thr_state.get());101 assert(thr_state.get());
@@ -106,11 +113,22 @@
106 query_execution_time.tv_usec +113 query_execution_time.tv_usec +
107 query_execution_time.tv_sec*1000000));114 query_execution_time.tv_sec*1000000));
108115
116 gettimeofday(&current_time, NULL);
117 timersub(&current_time,
118 &last_query_info.end_timestamp,
119 &tv_btw_query_end_and_result_start);
120
121 total_duration=
122 last_query_info.result.getDuration() +
123 boost::posix_time::microseconds(
124 tv_btw_query_end_and_result_start.tv_sec*1000000 +
125 tv_btw_query_end_and_result_start.tv_usec);
126
109 if (g_tcpdump_mode == TCPDUMP_MODE_ACCURATE &&127 if (g_tcpdump_mode == TCPDUMP_MODE_ACCURATE &&
110 (expected_result.getDuration() > last_query_info.result.getDuration()))128 (expected_result.getDuration() > total_duration))
111 {129 {
112 boost::posix_time::time_duration us_sleep_time=130 boost::posix_time::time_duration us_sleep_time=
113 expected_result.getDuration() - last_query_info.result.getDuration();131 expected_result.getDuration() - total_duration;
114132
115 usleep(us_sleep_time.total_microseconds());133 usleep(us_sleep_time.total_microseconds());
116 }134 }

Subscribers

People subscribed via source and target branches

to all changes: