Merge lp:~dshrews/drizzle/bug729397_optimize_io into lp:drizzle/7.0

Proposed by David Shrewsbury
Status: Merged
Approved by: Brian Aker
Approved revision: 2223
Merged at revision: 2222
Proposed branch: lp:~dshrews/drizzle/bug729397_optimize_io
Merge into: lp:drizzle/7.0
Diff against target: 120 lines (+39/-10)
2 files modified
plugin/slave/queue_producer.cc (+13/-8)
plugin/slave/queue_producer.h (+26/-2)
To merge this branch: bzr merge lp:~dshrews/drizzle/bug729397_optimize_io
Reviewer Review Type Date Requested Status
Drizzle Developers Pending
Review via email: mp+52442@code.launchpad.net

Description of the change

Changes the IO (producer) thread to continually pull from the master until it is caught up, at which point it will then sleep.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugin/slave/queue_producer.cc'
2--- plugin/slave/queue_producer.cc 2011-03-04 22:49:58 +0000
3+++ plugin/slave/queue_producer.cc 2011-03-07 17:40:50 +0000
4@@ -71,7 +71,12 @@
5 }
6 }
7
8- if (not queryForReplicationEvents(_saved_max_commit_id))
9+ /* Keep getting events until caught up */
10+ enum drizzled::error_t err;
11+ while ((err= (queryForReplicationEvents(_saved_max_commit_id))) == EE_OK)
12+ {}
13+
14+ if (err == ER_YES) /* We encountered an error */
15 {
16 if (_last_return == DRIZZLE_RETURN_LOST_CONNECTION)
17 {
18@@ -368,16 +373,16 @@
19 }
20
21
22-bool QueueProducer::queryForReplicationEvents(uint64_t max_commit_id)
23+enum drizzled::error_t QueueProducer::queryForReplicationEvents(uint64_t max_commit_id)
24 {
25 vector<uint64_t> trx_id_list;
26
27 if (not queryForTrxIdList(max_commit_id, trx_id_list))
28- return false;
29+ return ER_YES;
30
31 if (trx_id_list.size() == 0) /* nothing to get from the master */
32 {
33- return true;
34+ return ER_NO;
35 }
36
37 /*
38@@ -406,7 +411,7 @@
39 _last_error_message.append(drizzle_error(&_drizzle));
40 errmsg_printf(error::ERROR, _("%s"), _last_error_message.c_str());
41 drizzle_result_free(&result);
42- return false;
43+ return ER_YES;
44 }
45
46 /* TODO: Investigate 1-row-at-a-time buffering */
47@@ -420,7 +425,7 @@
48 _last_error_message.append(drizzle_error(&_drizzle));
49 errmsg_printf(error::ERROR, _("%s"), _last_error_message.c_str());
50 drizzle_result_free(&result);
51- return false;
52+ return ER_YES;
53 }
54
55 drizzle_row_t row;
56@@ -432,13 +437,13 @@
57 errmsg_printf(error::ERROR,
58 _("Replication slave: Unable to insert into queue."));
59 drizzle_result_free(&result);
60- return false;
61+ return ER_YES;
62 }
63 }
64
65 drizzle_result_free(&result);
66
67- return true;
68+ return EE_OK;
69 }
70
71
72
73=== modified file 'plugin/slave/queue_producer.h'
74--- plugin/slave/queue_producer.h 2011-02-28 14:33:56 +0000
75+++ plugin/slave/queue_producer.h 2011-03-07 17:40:50 +0000
76@@ -21,9 +21,10 @@
77 #ifndef PLUGIN_SLAVE_QUEUE_PRODUCER_H
78 #define PLUGIN_SLAVE_QUEUE_PRODUCER_H
79
80+#include <client/client_priv.h>
81+#include <drizzled/error_t.h>
82 #include <plugin/slave/queue_thread.h>
83 #include <plugin/slave/sql_executor.h>
84-#include <client/client_priv.h>
85 #include <string>
86 #include <vector>
87
88@@ -132,8 +133,31 @@
89 */
90 bool reconnect(bool initial_connection);
91
92+ /**
93+ * Get maximum commit ID that we have stored locally on the slave.
94+ *
95+ * This method determines where this slave is in relation to the master,
96+ * or, in other words, how "caught up" we are.
97+ *
98+ * @param[out] max_commit_id Maximum commit ID we have on this slave.
99+ */
100 bool queryForMaxCommitId(uint64_t *max_commit_id);
101- bool queryForReplicationEvents(uint64_t max_commit_id);
102+
103+ /**
104+ * Get replication events/messages from the master.
105+ *
106+ * Calling this method will a limited number of events from the master.
107+ * It should be repeatedly called until it returns -1, which means there
108+ * were no more events to retrieve.
109+ *
110+ * @param[in] max_commit_id Largest commit ID we have stored locally.
111+ *
112+ * @retval EE_OK Successfully retrieved events
113+ * @retval ER_NO No errors, but no more events to retrieve
114+ * @retval ER_YES Error
115+ */
116+ enum drizzled::error_t queryForReplicationEvents(uint64_t max_commit_id);
117+
118 bool queryForTrxIdList(uint64_t max_commit_id, std::vector<uint64_t> &list);
119 bool queueInsert(const char *trx_id,
120 const char *seg_id,

Subscribers

People subscribed via source and target branches