Skip to content

Commit

Permalink
drainer: skip 'alter table cache|nocache' DDL jobs (#1115)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored Dec 31, 2021
1 parent 3330cb7 commit e6686a3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drainer/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ func skipUnsupportedDDLJob(job *model.Job) bool {
// return true
case model.ActionLockTable, model.ActionUnlockTable:
return true
case model.ActionAlterCacheTable, model.ActionAlterNoCacheTable:
return true
case model.ActionAlterTableAttributes, model.ActionAlterTablePartitionAttributes:
return true
}
Expand Down
17 changes: 17 additions & 0 deletions tests/cache_table/drainer.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
data-dir = '/tmp/tidb_binlog_test/data.drainer'

[syncer]
txn-batch = 1
worker-count = 1
safe-mode = false
db-type = 'mysql'
replicate-do-db = ['cache_test']

[syncer.to]
host = '127.0.0.1'
user = 'root'
password = ''
port = 3306

[syncer.to.checkpoint]
schema = "cache_table_checkpoint"
28 changes: 28 additions & 0 deletions tests/cache_table/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

set -e

cd "$(dirname "$0")"

run_drainer &

sleep 3

run_sql 'CREATE DATABASE cache_test;'
run_sql 'CREATE TABLE cache_test.t1( a int, b varchar(128));'
run_sql "INSERT INTO cache_test.t1 (a,b) VALUES(1,'a'),(2,'b'),(3,'c'),(4,'d');"
run_sql "ALTER TABLE cache_test.t1 CACHE;"
run_sql "INSERT INTO cache_test.t1 (a,b) VALUES(5,'e'),(6,'f'),(7,'g'),(8,'h');"
run_sql "ALTER TABLE cache_test.t1 NOCACHE"

sleep 3

down_run_sql 'SELECT a, b FROM cache_test.t1 order by a'
check_contains 'a: 7'
check_contains 'b: g'
check_contains 'a: 8'
check_contains 'b: h'

run_sql 'DROP DATABASE cache_test'

killall drainer

0 comments on commit e6686a3

Please sign in to comment.