diff --git a/ddl/schema.go b/ddl/schema.go index 12dd8147b5..6b9457045f 100644 --- a/ddl/schema.go +++ b/ddl/schema.go @@ -61,27 +61,14 @@ func (d *ddl) onCreateSchema(t *meta.Meta, job *model.Job) error { switch dbInfo.State { case model.StateNone: - // none -> delete only - job.SchemaState = model.StateDeleteOnly - dbInfo.State = model.StateDeleteOnly - err = t.CreateDatabase(dbInfo) - return errors.Trace(err) - case model.StateDeleteOnly: - // delete only -> write only - job.SchemaState = model.StateWriteOnly - dbInfo.State = model.StateWriteOnly - err = t.UpdateDatabase(dbInfo) - return errors.Trace(err) - case model.StateWriteOnly: - // write only -> public + // none -> public job.SchemaState = model.StatePublic dbInfo.State = model.StatePublic - err = t.UpdateDatabase(dbInfo) + err = t.CreateDatabase(dbInfo) if err != nil { return errors.Trace(err) } - - // finish this job. + // finish this job job.State = model.JobDone return nil default: diff --git a/ddl/table.go b/ddl/table.go index ddd1903341..123d1efa26 100644 --- a/ddl/table.go +++ b/ddl/table.go @@ -60,26 +60,13 @@ func (d *ddl) onCreateTable(t *meta.Meta, job *model.Job) error { switch tbInfo.State { case model.StateNone: - // none -> delete only - job.SchemaState = model.StateDeleteOnly - tbInfo.State = model.StateDeleteOnly - err = t.CreateTable(schemaID, tbInfo) - return errors.Trace(err) - case model.StateDeleteOnly: - // delete only -> write only - job.SchemaState = model.StateWriteOnly - tbInfo.State = model.StateWriteOnly - err = t.UpdateTable(schemaID, tbInfo) - return errors.Trace(err) - case model.StateWriteOnly: - // write only -> public + // none -> public job.SchemaState = model.StatePublic tbInfo.State = model.StatePublic - err = t.UpdateTable(schemaID, tbInfo) + err = t.CreateTable(schemaID, tbInfo) if err != nil { return errors.Trace(err) } - // finish this job job.State = model.JobDone return nil diff --git a/interpreter/main.go b/interpreter/main.go index 2d0d10fb91..c9a4ddabfb 100644 --- a/interpreter/main.go +++ b/interpreter/main.go @@ -35,7 +35,7 @@ var ( logLevel = flag.String("L", "error", "log level") store = flag.String("store", "goleveldb", "the name for the registered storage, e.g. memory, goleveldb, boltdb") dbPath = flag.String("dbpath", "test/test", "db path") - lease = flag.Int("lease", 300, "schema lease seconds, very dangerous to change only if you know what you do") + lease = flag.Int("lease", 1, "schema lease seconds, very dangerous to change only if you know what you do") line *liner.State historyPath = "/tmp/tidb_interpreter" diff --git a/tidb-server/main.go b/tidb-server/main.go index 5dd6a2dece..caa791b25a 100644 --- a/tidb-server/main.go +++ b/tidb-server/main.go @@ -34,7 +34,7 @@ var ( storePath = flag.String("path", "/tmp/tidb", "tidb storage path") logLevel = flag.String("L", "debug", "log level: info, debug, warn, error, fatal") port = flag.String("P", "4000", "mp server port") - lease = flag.Int("lease", 300, "schema lease seconds, very dangerous to change only if you know what you do") + lease = flag.Int("lease", 1, "schema lease seconds, very dangerous to change only if you know what you do") ) func main() { diff --git a/tidb.go b/tidb.go index 395572aca7..7285e0af51 100644 --- a/tidb.go +++ b/tidb.go @@ -92,12 +92,13 @@ var ( // store.UUID()-> IfBootstrapped storeBootstrapped = make(map[string]bool) - // SchemaLease is the time(seconds) for re-updating remote schema. + // schemaLease is the time for re-updating remote schema. // In online DDL, we must wait 2 * SchemaLease time to guarantee // all servers get the neweset schema. - // Default schema lease time is 300 seconds, you can change it with a proper time, + // Default schema lease time is 1 second, you can change it with a proper time, // but you must know that too little may cause badly performance degradation. - schemaLease = 300 * time.Second + // For production, you should set a big schema lease, like 300s+. + schemaLease = 1 * time.Second ) // SetSchemaLease changes the default schema lease time for DDL.