Skip to content

Commit

Permalink
Add --transaction-isolation flag
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Aug 14, 2024
1 parent 59db6fa commit 544f5b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions go/base/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package base

import (
"errors"
"fmt"
"math"
"os"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion go/cmd/gh-ost/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 544f5b1

Please sign in to comment.