transaction log attributing statements to wrong tables on multi-table, multi-statement transactions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Drizzle |
Fix Released
|
Medium
|
Joe Daly | ||
Dexter |
Fix Released
|
Medium
|
Joe Daly |
Bug Description
The transaction log is attributing statements to the wrong table (the first used) for multi-table, multi-statement transactions.
For this set of queries:
CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL, PRIMARY KEY(a), KEY b_key1 (b));
CREATE TABLE t2 LIKE t1;
START TRANSACTION;
INSERT INTO t1 (b) VALUES (1),(2)
INSERT INTO t2 (b) VALUES (1),(2)
UPDATE t1 SET b = b*10 WHERE b%2=0;
UPDATE t2 SET b = b/10 WHERE b%2=0;
COMMIT;
We get this transaction log ouput:
NOTE: Both the INSERT and UPDATE against t2 are attributed to t1.
+SELECT PRINT_TRANSACTI
+PRINT_
+transaction_
+ server_id: 1
+ transaction_id: 5
+ START_TIMESTAMP
+ END_TIMESTAMP
+}
+statement {
+ type: INSERT
+ START_TIMESTAMP
+ END_TIMESTAMP
+ insert_header {
+ table_metadata {
+ schema_name: "test"
+ table_name: "t1"
+ }
+ field_metadata {
+ type: INTEGER
+ name: "a"
+ }
+ field_metadata {
+ type: INTEGER
+ name: "b"
+ }
+ }
+ insert_data {
+ segment_id: 1
+ end_segment: true
+ record {
+ insert_value: "1"
+ insert_value: "1"
+ }
+ record {
+ insert_value: "2"
+ insert_value: "2"
+ }
+ record {
+ insert_value: "3"
+ insert_value: "3"
+ }
+ record {
+ insert_value: "4"
+ insert_value: "4"
+ }
+ record {
+ insert_value: "5"
+ insert_value: "5"
+ }
+ record {
+ insert_value: "6"
+ insert_value: "6"
+ }
+ record {
+ insert_value: "7"
+ insert_value: "7"
+ }
+ record {
+ insert_value: "8"
+ insert_value: "8"
+ }
+ record {
+ insert_value: "9"
+ insert_value: "9"
+ }
+ record {
+ insert_value: "10"
+ insert_value: "10"
+ }
+ record {
+ insert_value: "11"
+ insert_value: "100"
+ }
+ record {
+ insert_value: "12"
+ insert_value: "101"
+ }
+ record {
+ insert_value: "1"
+ insert_value: "1"
+ }
+ record {
+ insert_value: "2"
+ insert_value: "2"
+ }
+ record {
+ insert_value: "3"
+ insert_value: "3"
+ }
+ record {
+ insert_value: "4"
+ insert_value: "4"
+ }
+ record {
+ insert_value: "5"
+ insert_value: "5"
+ }
+ record {
+ insert_value: "6"
+ insert_value: "6"
+ }
+ record {
+ insert_value: "7"
+ insert_value: "7"
+ }
+ record {
+ insert_value: "8"
+ insert_value: "8"
+ }
+ record {
+ insert_value: "9"
+ insert_value: "9"
+ }
+ record {
+ insert_value: "10"
+ insert_value: "10"
+ }
+ record {
+ insert_value: "11"
+ insert_value: "100"
+ }
+ record {
+ insert_value: "12"
+ insert_value: "101"
+ }
+ }
+}
+statement {
+ type: UPDATE
+ start_timestamp: 1277844822567193
+ end_timestamp: 1277844822568660
+ update_header {
+ table_metadata {
+ schema_name: "test"
+ table_name: "t1"
+ }
+ key_field_metadata {
+ type: INTEGER
+ name: "a"
+ }
+ set_field_metadata {
+ type: INTEGER
+ name: "b"
+ }
+ }
+ update_data {
+ segment_id: 1
+ end_segment: true
+ record {
+ key_value: "2"
+ after_value: "20"
+ }
+ record {
+ key_value: "4"
+ after_value: "40"
+ }
+ record {
+ key_value: "6"
+ after_value: "60"
+ }
+ record {
+ key_value: "8"
+ after_value: "80"
+ }
+ record {
+ key_value: "10"
+ after_value: "100"
+ }
+ record {
+ key_value: "11"
+ after_value: "1000"
+ }
+ record {
+ key_value: "2"
+ after_value: "0"
+ }
+ record {
+ key_value: "4"
+ after_value: "0"
+ }
+ record {
+ key_value: "6"
+ after_value: "1"
+ }
+ record {
+ key_value: "8"
+ after_value: "1"
+ }
+ record {
+ key_value: "10"
+ after_value: "1"
+ }
+ record {
+ key_value: "11"
+ after_value: "10"
+ }
+ }
+}
Related branches
- Drizzle Developers: Pending requested
- Brian Aker: Pending requested
-
Diff: 236 lines (+159/-17)5 files modifieddrizzled/transaction_services.cc (+62/-17)
plugin/transaction_log/tests/r/multi_table.result (+51/-0)
plugin/transaction_log/tests/t/multi_table-master.opt (+1/-0)
plugin/transaction_log/tests/t/multi_table.inc (+32/-0)
plugin/transaction_log/tests/t/multi_table.test (+13/-0)
Changed in drizzle: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
Changed in drizzle: | |
assignee: | nobody → Joe Daly (skinny.moey) |
This does not appear to be the case for all multi-table, multi-statement transactions:
<snip>
...
DELETE FROM t2 WHERE b%10=0 ;
INSERT INTO t1 (b) VALUES (10),(15);
COMMIT;
For this code, the INSERT message is properly attributed to t1. It seems that if the actions (INSERT, DELETE, UPDATE) differ, that the messages will be correct.
However, something like:
INSERT INTO t1...
INSERT INTO t2...
will fail / register everything as belonging to t1.