~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/transaction_log/transaction_log.cc

* Fixes drizzled's atomics:

- fetch_and_add() was actually add_and_fetch() - fixed to have both methods correct
- compare_and_swap() was incorrect for all traits classes.  Fixed to return a bool
true only when the supplied value is actually swapped
- fixes increment() and decrement() methods and operator+=() in outer atomics class
template to call proper add_and_fetch() methods on traits classes
- Now that above are fixed, removed the hacks in Query_id and TransactionLog to
have query ID and the new transactoin ID start properly at 1.

* Transaction messages sent over replication stream now use
a real transaction ID, managed by drizzled::TransactionServices.  Previously, 
the Query_id was being used, resulting in SELECT statements incrementing the
transaction ID.

* Added a test case to ensure that DDL ops are given a transaction ID and SELECT
ops do not increment the transaction ID.

The transaction ID will be paired with a channel ID to become the global
transaction identifier.  ReplicationServices will manage the pairing of
channel and transaction ID and understand how far a particular subscriber
node has applied.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
#include <drizzled/errmsg_print.h>
85
85
#include <drizzled/gettext.h>
86
86
#include <drizzled/message/transaction.pb.h>
 
87
#include <drizzled/transaction_services.h>
87
88
#include <drizzled/algorithm/crc32.h>
88
89
 
89
90
#include <google/protobuf/io/coded_stream.h>
192
193
   */
193
194
  off_t cur_offset= log_offset.fetch_and_add(static_cast<off_t>(data_length));
194
195
 
195
 
  /*
196
 
   * We adjust cur_offset back to the original log_offset before
197
 
   * the increment above...
198
 
   */
199
 
  cur_offset-= static_cast<off_t>(data_length);
200
 
 
201
196
  /* 
202
197
   * Quick safety...if an error occurs above in another writer, the log 
203
198
   * file will be in a crashed state.
293
288
    result= ftruncate(log_file, log_offset);
294
289
  }
295
290
  while (result == -1 && errno == EINTR);
 
291
  drizzled::TransactionServices::singleton().resetTransactionId();
296
292
}
297
293
 
298
294
bool TransactionLog::findLogFilenameContainingTransactionId(const ReplicationServices::GlobalTransactionId&,