Merge lp:~dshrews/drizzle/bugs_626566_637590 into lp:~drizzle-trunk/drizzle/development

Proposed by David Shrewsbury
Status: Merged
Approved by: Brian Aker
Approved revision: 1762
Merged at revision: 1766
Proposed branch: lp:~dshrews/drizzle/bugs_626566_637590
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 104 lines (+29/-4)
1 file modified
drizzled/transaction_services.cc (+29/-4)
To merge this branch: bzr merge lp:~dshrews/drizzle/bugs_626566_637590
Reviewer Review Type Date Requested Status
Brian Aker Needs Information
Review via email: mp+35353@code.launchpad.net

Description of the change

The segment_id of Statement messages wasn't remaining set to its proper value when a Transaction message had to be split up due to exceed message size. This broke the rollback code since it could not identify bulk load messages.

Also fixed calculating the current message size by using the Transaction message rather than its embedded Statement messages.

Also also, during a ROLLBACK, the transaction id was improperly incremented.

To post a comment you must log in.
Revision history for this message
Brian Aker (brianaker) wrote :

Anyway to add a test case for the rollback?

review: Needs Information
Revision history for this message
David Shrewsbury (dshrews) wrote :

Good question Brian. Since this is testing the GPB messages themselves, we don't yet have a good way to test that part. But I'm working with Patrick to implement a plan to do just that. So this is something that is coming in the near future.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/transaction_services.cc'
2--- drizzled/transaction_services.cc 2010-09-11 20:23:04 +0000
3+++ drizzled/transaction_services.cc 2010-09-14 00:21:01 +0000
4@@ -1072,7 +1072,7 @@
5 * attach it to the transaction, and push it to replicators.
6 */
7 transaction->Clear();
8- initTransactionMessage(*transaction, in_session, true);
9+ initTransactionMessage(*transaction, in_session, false);
10
11 message::Statement *statement= transaction->add_statement();
12
13@@ -1107,12 +1107,14 @@
14 }
15 else if (statement != NULL)
16 {
17+ transaction= getActiveTransactionMessage(in_session);
18+
19 /*
20 * If we've passed our threshold for the statement size (possible for
21 * a bulk insert), we'll finalize the Statement and Transaction (doing
22 * the Transaction will keep it from getting huge).
23 */
24- if (static_cast<size_t>(statement->ByteSize()) >= trx_msg_threshold)
25+ if (static_cast<size_t>(transaction->ByteSize()) >= trx_msg_threshold)
26 {
27 message::InsertData *current_data= statement->mutable_insert_data();
28
29@@ -1143,11 +1145,18 @@
30
31 string current_table_name;
32 (void) in_table->getShare()->getTableName(current_table_name);
33+
34 if (current_table_name.compare(old_table_name))
35 {
36 finalizeStatementMessage(*statement, in_session);
37 statement= in_session->getStatementMessage();
38 }
39+ else
40+ {
41+ /* carry forward the existing segment id */
42+ const message::InsertData &current_data= statement->insert_data();
43+ *next_segment_id= current_data.segment_id();
44+ }
45 }
46 }
47
48@@ -1288,12 +1297,14 @@
49 }
50 else if (statement != NULL)
51 {
52+ transaction= getActiveTransactionMessage(in_session);
53+
54 /*
55 * If we've passed our threshold for the statement size (possible for
56 * a bulk insert), we'll finalize the Statement and Transaction (doing
57 * the Transaction will keep it from getting huge).
58 */
59- if (static_cast<size_t>(statement->ByteSize()) >= trx_msg_threshold)
60+ if (static_cast<size_t>(transaction->ByteSize()) >= trx_msg_threshold)
61 {
62 message::UpdateData *current_data= statement->mutable_update_data();
63
64@@ -1329,6 +1340,12 @@
65 finalizeStatementMessage(*statement, in_session);
66 statement= in_session->getStatementMessage();
67 }
68+ else
69+ {
70+ /* carry forward the existing segment id */
71+ const message::UpdateData &current_data= statement->update_data();
72+ *next_segment_id= current_data.segment_id();
73+ }
74 }
75 }
76
77@@ -1535,12 +1552,14 @@
78 }
79 else if (statement != NULL)
80 {
81+ transaction= getActiveTransactionMessage(in_session);
82+
83 /*
84 * If we've passed our threshold for the statement size (possible for
85 * a bulk insert), we'll finalize the Statement and Transaction (doing
86 * the Transaction will keep it from getting huge).
87 */
88- if (static_cast<size_t>(statement->ByteSize()) >= trx_msg_threshold)
89+ if (static_cast<size_t>(transaction->ByteSize()) >= trx_msg_threshold)
90 {
91 message::DeleteData *current_data= statement->mutable_delete_data();
92
93@@ -1576,6 +1595,12 @@
94 finalizeStatementMessage(*statement, in_session);
95 statement= in_session->getStatementMessage();
96 }
97+ else
98+ {
99+ /* carry forward the existing segment id */
100+ const message::DeleteData &current_data= statement->delete_data();
101+ *next_segment_id= current_data.segment_id();
102+ }
103 }
104 }
105