diff --git a/doc/command-line-flags.md b/doc/command-line-flags.md index cf2b2ca95..82281c4ea 100644 --- a/doc/command-line-flags.md +++ b/doc/command-line-flags.md @@ -294,6 +294,10 @@ Defaults to 1000 (1 second). Configures the HTTP throttler check timeout in mill Makes the _old_ table include a timestamp value. The _old_ table is what the original table is renamed to at the end of a successful migration. For example, if the table is `gh_ost_test`, then the _old_ table would normally be `_gh_ost_test_del`. With `--timestamp-old-table` it would be, for example, `_gh_ost_test_20170221103147_del`. +### transaction-isolation + +Defaults to `REPEATABLE-READ`. Configures the session-level transaction isolation level used for applier and inspector connections. Possible values: `REPEATABLE-READ` or `READ-COMMITTED`. + ### tungsten See [`tungsten`](cheatsheet.md#tungsten) on the cheatsheet. diff --git a/go/base/context.go b/go/base/context.go index 59227ea2d..7569fa697 100644 --- a/go/base/context.go +++ b/go/base/context.go @@ -6,6 +6,7 @@ package base import ( + "errors" "fmt" "math" "os" @@ -293,13 +294,16 @@ func NewMigrationContext() *MigrationContext { } } -func (this *MigrationContext) SetConnectionConfig(storageEngine string) error { - var transactionIsolation string +func (this *MigrationContext) SetConnectionConfig(storageEngine, transactionIsolation string) error { switch storageEngine { case "rocksdb": transactionIsolation = "READ-COMMITTED" default: - transactionIsolation = "REPEATABLE-READ" + switch transactionIsolation { + case "READ-COMMITTED", "REPEATABLE-READ": + default: + return errors.New("unsupported transaction isolation level") + } } this.InspectorConnectionConfig.TransactionIsolation = transactionIsolation this.ApplierConnectionConfig.TransactionIsolation = transactionIsolation diff --git a/go/cmd/gh-ost/main.go b/go/cmd/gh-ost/main.go index 3e6057995..8d5e6b52d 100644 --- a/go/cmd/gh-ost/main.go +++ b/go/cmd/gh-ost/main.go @@ -108,6 +108,7 @@ func main() { dmlBatchSize := flag.Int64("dml-batch-size", 10, "batch size for DML events to apply in a single transaction (range 1-100)") defaultRetries := flag.Int64("default-retries", 60, "Default number of retries for various operations before panicking") cutOverLockTimeoutSeconds := flag.Int64("cut-over-lock-timeout-seconds", 3, "Max number of seconds to hold locks on tables while attempting to cut-over (retry attempted when lock exceeds timeout)") + transactionIsolation := flag.String("transaction-isolation", "REPEATABLE-READ", "transaction isolation level to be used by the applier and inspector. Possible values: REPEATABLE-READ or READ-COMMITTED") niceRatio := flag.Float64("nice-ratio", 0, "force being 'nice', imply sleep time per chunk time; range: [0.0..100.0]. Example values: 0 is aggressive. 1: for every 1ms spent copying rows, sleep additional 1ms (effectively doubling runtime); 0.7: for every 10ms spend in a rowcopy chunk, spend 7ms sleeping immediately after") maxLagMillis := flag.Int64("max-lag-millis", 1500, "replication lag at which to throttle operation") @@ -188,7 +189,7 @@ func main() { migrationContext.Log.SetLevel(log.ERROR) } - if err := migrationContext.SetConnectionConfig(*storageEngine); err != nil { + if err := migrationContext.SetConnectionConfig(*storageEngine, *transactionIsolation); err != nil { migrationContext.Log.Fatale(err) }