DROP SCHEMA/TABLE IF EXISTS being logged even if the object didn't exist

Bug #674471 reported by Patrick Crews
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Drizzle
Fix Released
Medium
David Shrewsbury
7.0
Fix Released
Medium
David Shrewsbury

Bug Description

If you issue a DROP SCHEMA IF EXISTS $schema, the transaction log is recording this as DROP SCHEMA $schema.

This is problematic as trying to execute the SQL from this would result in an error *and* the log is recording something that didn't actually happen.

I'll create a branch with a test-case shortly, but here is an example.

./test.run --start-and-exit --drizzled=--transaction-log.enable
DROP SCHEMA IF EXISTS bobo;

select print_transaction_message('transaction.log',(select max(entry_offset) from data_dictionary.transaction_log_entries));
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| print_transaction_message('transaction.log',(select max(entry_offset) from data_dictionary.transaction_log_entries)) |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| transaction_context {
  server_id: 1
  transaction_id: 772
  start_timestamp: 1289563680419957
  end_timestamp: 1289563680419970
}
statement {
  type: DROP_SCHEMA
  start_timestamp: 1289563680419967
  end_timestamp: 1289563680419970
  drop_schema_statement {
    schema_name: "bobo"
  }
}
 |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0 sec)

Tags: replication

Related branches

Changed in drizzle:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → David Shrewsbury (dshrews)
Revision history for this message
Patrick Crews (patrick-crews) wrote :

Also happens for DROP TABLE IF

summary: - DROP SCHEMA IF EXISTS being logged as DROP SCHEMA even if there is no
- schema to drop
+ DROP SCHEMA/TABLE IF EXISTS being logged even if the object didn't exist
Revision history for this message
Patrick Crews (patrick-crews) wrote :

transaction_log.transaction_log_drop.test has been updated.

Sadly we had a test case in there, but I didn't flag the behavior as a bug until now. Added a DROP SCHEMA query to the bug's test case and updated the commenting to indicate that this is attached to this bug.

Revision history for this message
Patrick Crews (patrick-crews) wrote :

grrr. I meant updated in the attached branch. It needs to be re-recorded once behavior is correct, so no .result provided.

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

The proto definition for a DROP SCHEMA statement is missing a boolean to track whether or not the IF EXISTS clause was used.

Changed in drizzle:
milestone: none → 2011-01-03
status: Confirmed → Triaged
importance: High → Medium
tags: added: replication
Changed in drizzle:
status: Triaged → In Progress
Revision history for this message
David Shrewsbury (dshrews) wrote :

Apparently I concentrated too much on the description and not the title before I posted my last comment.

I don't believe that a DROP SCHEMA/TABLE should be logged at all to the transaction log if it did not drop anything. This is confusing behavior, in my opinion. Are we logging the db changes, or are we logging the statements regardless of their effects? I think it should be the db changes only.

Confusingly, the DropTable protobuf message carries an if_exists_clause boolean to indicate if the IF EXISTS clause was used (DropSchema does not). I intend to remove this boolean and only log these statements if an actual change was made. As a side effect of this, output from the transaction_reader will never produce an IF EXISTS clause because it should never be needed.

Changed in drizzle:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.