From 544f5b1856b16b7ce974874778aee762d655c861 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Thu, 15 Aug 2024 00:37:01 +0200 Subject: [PATCH 1/3] Add `--transaction-isolation` flag Signed-off-by: Tim Vaillancourt --- go/base/context.go | 10 +++++++--- go/cmd/gh-ost/main.go | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/go/base/context.go b/go/base/context.go index 41baae696..f37be0c18 100644 --- a/go/base/context.go +++ b/go/base/context.go @@ -6,6 +6,7 @@ package base import ( + "errors" "fmt" "math" "os" @@ -292,13 +293,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 39c815bc8..85129e1c3 100644 --- a/go/cmd/gh-ost/main.go +++ b/go/cmd/gh-ost/main.go @@ -109,6 +109,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 options: 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") @@ -189,7 +190,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) } From cfd4ff302cc76d38f3b9ccbcb21d55f947de0afd Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Thu, 15 Aug 2024 03:19:35 +0200 Subject: [PATCH 2/3] docs Signed-off-by: Tim Vaillancourt --- doc/command-line-flags.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/command-line-flags.md b/doc/command-line-flags.md index dd8f1cd74..9a1d6c207 100644 --- a/doc/command-line-flags.md +++ b/doc/command-line-flags.md @@ -298,6 +298,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. + ### tungsten See [`tungsten`](cheatsheet.md#tungsten) on the cheatsheet. From 196cecfaa1a831c1051e534244f04f261d8a5bce Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Thu, 15 Aug 2024 03:22:59 +0200 Subject: [PATCH 3/3] doc update Signed-off-by: Tim Vaillancourt --- doc/command-line-flags.md | 2 +- go/cmd/gh-ost/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/command-line-flags.md b/doc/command-line-flags.md index 9a1d6c207..75dca1c5f 100644 --- a/doc/command-line-flags.md +++ b/doc/command-line-flags.md @@ -300,7 +300,7 @@ Makes the _old_ table include a timestamp value. The _old_ table is what the ori ### transaction-isolation -Defaults to REPEATABLE-READ. Configures the session-level transaction isolation level used for applier and inspector connections. +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 diff --git a/go/cmd/gh-ost/main.go b/go/cmd/gh-ost/main.go index 85129e1c3..b4fba12bf 100644 --- a/go/cmd/gh-ost/main.go +++ b/go/cmd/gh-ost/main.go @@ -109,7 +109,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 options: REPEATABLE-READ or READ-COMMITTED") + 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")