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
=== modified file 'plugin/slave/queue_producer.cc'
--- plugin/slave/queue_producer.cc 2011-03-04 22:49:58 +0000
+++ plugin/slave/queue_producer.cc 2011-03-07 17:40:50 +0000
@@ -71,7 +71,12 @@
71 }71 }
72 }72 }
7373
74 if (not queryForReplicationEvents(_saved_max_commit_id))74 /* Keep getting events until caught up */
75 enum drizzled::error_t err;
76 while ((err= (queryForReplicationEvents(_saved_max_commit_id))) == EE_OK)
77 {}
78
79 if (err == ER_YES) /* We encountered an error */
75 {80 {
76 if (_last_return == DRIZZLE_RETURN_LOST_CONNECTION)81 if (_last_return == DRIZZLE_RETURN_LOST_CONNECTION)
77 {82 {
@@ -368,16 +373,16 @@
368}373}
369374
370375
371bool QueueProducer::queryForReplicationEvents(uint64_t max_commit_id)376enum drizzled::error_t QueueProducer::queryForReplicationEvents(uint64_t max_commit_id)
372{377{
373 vector<uint64_t> trx_id_list;378 vector<uint64_t> trx_id_list;
374379
375 if (not queryForTrxIdList(max_commit_id, trx_id_list))380 if (not queryForTrxIdList(max_commit_id, trx_id_list))
376 return false;381 return ER_YES;
377382
378 if (trx_id_list.size() == 0) /* nothing to get from the master */383 if (trx_id_list.size() == 0) /* nothing to get from the master */
379 {384 {
380 return true;385 return ER_NO;
381 }386 }
382387
383 /*388 /*
@@ -406,7 +411,7 @@
406 _last_error_message.append(drizzle_error(&_drizzle));411 _last_error_message.append(drizzle_error(&_drizzle));
407 errmsg_printf(error::ERROR, _("%s"), _last_error_message.c_str());412 errmsg_printf(error::ERROR, _("%s"), _last_error_message.c_str());
408 drizzle_result_free(&result);413 drizzle_result_free(&result);
409 return false;414 return ER_YES;
410 }415 }
411416
412 /* TODO: Investigate 1-row-at-a-time buffering */417 /* TODO: Investigate 1-row-at-a-time buffering */
@@ -420,7 +425,7 @@
420 _last_error_message.append(drizzle_error(&_drizzle));425 _last_error_message.append(drizzle_error(&_drizzle));
421 errmsg_printf(error::ERROR, _("%s"), _last_error_message.c_str());426 errmsg_printf(error::ERROR, _("%s"), _last_error_message.c_str());
422 drizzle_result_free(&result);427 drizzle_result_free(&result);
423 return false;428 return ER_YES;
424 }429 }
425430
426 drizzle_row_t row;431 drizzle_row_t row;
@@ -432,13 +437,13 @@
432 errmsg_printf(error::ERROR,437 errmsg_printf(error::ERROR,
433 _("Replication slave: Unable to insert into queue."));438 _("Replication slave: Unable to insert into queue."));
434 drizzle_result_free(&result);439 drizzle_result_free(&result);
435 return false;440 return ER_YES;
436 }441 }
437 }442 }
438443
439 drizzle_result_free(&result);444 drizzle_result_free(&result);
440445
441 return true;446 return EE_OK;
442}447}
443448
444449
445450
=== modified file 'plugin/slave/queue_producer.h'
--- plugin/slave/queue_producer.h 2011-02-28 14:33:56 +0000
+++ plugin/slave/queue_producer.h 2011-03-07 17:40:50 +0000
@@ -21,9 +21,10 @@
21#ifndef PLUGIN_SLAVE_QUEUE_PRODUCER_H21#ifndef PLUGIN_SLAVE_QUEUE_PRODUCER_H
22#define PLUGIN_SLAVE_QUEUE_PRODUCER_H22#define PLUGIN_SLAVE_QUEUE_PRODUCER_H
2323
24#include <client/client_priv.h>
25#include <drizzled/error_t.h>
24#include <plugin/slave/queue_thread.h>26#include <plugin/slave/queue_thread.h>
25#include <plugin/slave/sql_executor.h>27#include <plugin/slave/sql_executor.h>
26#include <client/client_priv.h>
27#include <string>28#include <string>
28#include <vector>29#include <vector>
2930
@@ -132,8 +133,31 @@
132 */133 */
133 bool reconnect(bool initial_connection);134 bool reconnect(bool initial_connection);
134135
136 /**
137 * Get maximum commit ID that we have stored locally on the slave.
138 *
139 * This method determines where this slave is in relation to the master,
140 * or, in other words, how "caught up" we are.
141 *
142 * @param[out] max_commit_id Maximum commit ID we have on this slave.
143 */
135 bool queryForMaxCommitId(uint64_t *max_commit_id);144 bool queryForMaxCommitId(uint64_t *max_commit_id);
136 bool queryForReplicationEvents(uint64_t max_commit_id);145
146 /**
147 * Get replication events/messages from the master.
148 *
149 * Calling this method will a limited number of events from the master.
150 * It should be repeatedly called until it returns -1, which means there
151 * were no more events to retrieve.
152 *
153 * @param[in] max_commit_id Largest commit ID we have stored locally.
154 *
155 * @retval EE_OK Successfully retrieved events
156 * @retval ER_NO No errors, but no more events to retrieve
157 * @retval ER_YES Error
158 */
159 enum drizzled::error_t queryForReplicationEvents(uint64_t max_commit_id);
160
137 bool queryForTrxIdList(uint64_t max_commit_id, std::vector<uint64_t> &list);161 bool queryForTrxIdList(uint64_t max_commit_id, std::vector<uint64_t> &list);
138 bool queueInsert(const char *trx_id,162 bool queueInsert(const char *trx_id,
139 const char *seg_id,163 const char *seg_id,

Subscribers

People subscribed via source and target branches