You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add trigger support to gh-ost based on openark#30
* Add comprehensive test cases for trigger support functionality
* Fix trigger-basic test by adding required --trigger-suffix parameter and remove fail-trigger-unsupported test
* Update trigger suffix in local test configurations
Modify extra_args files for trigger-complex, trigger-multiple, and trigger-self-reference tests to use different trigger suffixes
* Add --remove-trigger-suffix-if-exists to local test configurations
Update extra_args files for trigger tests to include the new --remove-trigger-suffix-if-exists option, ensuring consistent trigger handling across different test scenarios
* Fix trigger-long-name test by reducing trigger name length to be valid
* Standardize trigger drop statements in local test configurations
Update create.sql files across trigger test scenarios to:
- Consistently drop both original and ghost triggers
- Ensure clean slate before creating triggers
- Align with recent trigger suffix changes
This change improves test reliability and consistency by explicitly dropping all potential trigger variations before test setup.
* Consolidate and enhance trigger test configurations
Refactor local test scenarios for triggers by:
- Merging multiple trigger test configurations into comprehensive test cases
- Updating create.sql files with more complex and diverse trigger scenarios
- Standardizing trigger and table setup across different test configurations
- Removing redundant test directories while preserving test coverage
This change simplifies the trigger testing infrastructure and provides more robust test coverage for gh-ost's trigger handling capabilities.
* Add debug logging for ghost trigger validation process
Enhance ghost trigger existence check by adding detailed debug logging to:
- Log the ghost trigger name being searched
- Log the database schema and query details
- Log when an existing ghost trigger is found
This change improves visibility into the trigger validation process, making troubleshooting easier during migration scenarios.
* Improve ghost trigger validation with enhanced logging and verification
Modify validateGhostTriggersDontExist() to:
- Add a direct query to log all triggers in the database schema
- Refactor trigger existence check to use count-based query
- Improve debug logging for trigger validation process
- Provide more detailed error reporting for existing ghost triggers
This change enhances the robustness and observability of the trigger validation mechanism in gh-ost's migration process.
* Refactor ghost trigger validation to improve logging and error detection
Simplify and enhance the validateGhostTriggersDontExist() method by:
- Removing redundant direct query logging
- Streamlining trigger existence check
- Improving debug logging for trigger validation
- Consolidating trigger existence detection logic
The changes provide more concise and focused trigger validation with clearer error reporting.
* Simplify ghost trigger validation query and reduce logging verbosity
Refactor validateGhostTriggersDontExist() to:
- Streamline trigger existence check query
- Remove redundant debug logging statements
- Use a more concise approach to detecting existing triggers
The changes reduce code complexity while maintaining the core validation logic for ghost triggers.
* Enhance ghost trigger validation query to include table name filter
Modify validateGhostTriggersDontExist() to:
- Add table name filter to trigger existence check query
- Improve specificity of ghost trigger detection
- Prevent false positives from similarly named triggers in different tables
The change ensures more precise ghost trigger validation by incorporating the original table name into the query criteria.
* Enhance trigger test configuration with advanced features and consolidated test scenarios
Update trigger-advanced-features test configuration to:
- Add new column 'color' and 'modified_count' to test table
- Implement more complex trigger logic for color and count tracking
- Consolidate trigger test scenarios with richer data transformations
- Modify event to test both numeric and color-based updates
- Remove redundant trigger-basic-features directory
The changes provide a more comprehensive and nuanced test suite for gh-ost's trigger handling capabilities, demonstrating advanced trigger behaviors and self-referencing updates.
* Fix lint errors
* Update trigger test configuration with suffix change
Modify the extra_args file to use '_ght' trigger suffix instead of '_gho', maintaining consistency with recent trigger test configuration updates.
* Remove gh-ost-ci-env submodule
Clean up repository by removing the gh-ost-ci-env submodule, which appears to be no longer needed in the project structure.
* Update create.sql
---------
Co-authored-by: Yakir Gibraltar <yakir.g@taboola.com>
Copy file name to clipboardExpand all lines: go/cmd/gh-ost/main.go
+19-1Lines changed: 19 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ import (
11
11
"net/url"
12
12
"os"
13
13
"os/signal"
14
+
"regexp"
14
15
"syscall"
15
16
16
17
"github.com/github/gh-ost/go/base"
@@ -137,6 +138,10 @@ func main() {
137
138
flag.UintVar(&migrationContext.ReplicaServerId, "replica-server-id", 99999, "server id used by gh-ost process. Default: 99999")
138
139
flag.IntVar(&migrationContext.BinlogSyncerMaxReconnectAttempts, "binlogsyncer-max-reconnect-attempts", 0, "when master node fails, the maximum number of binlog synchronization attempts to reconnect. 0 is unlimited")
139
140
141
+
flag.BoolVar(&migrationContext.IncludeTriggers, "include-triggers", false, "When true, the triggers (if exist) will be created on the new table")
142
+
flag.StringVar(&migrationContext.TriggerSuffix, "trigger-suffix", "", "Add a suffix to the trigger name (i.e '_v2'). Requires '--include-triggers'")
143
+
flag.BoolVar(&migrationContext.RemoveTriggerSuffix, "remove-trigger-suffix-if-exists", false, "Remove given suffix from name of trigger. Requires '--include-triggers' and '--trigger-suffix'")
144
+
140
145
maxLoad:=flag.String("max-load", "", "Comma delimited status-name=threshold. e.g: 'Threads_running=100,Threads_connected=500'. When status exceeds threshold, app throttles writes")
141
146
criticalLoad:=flag.String("critical-load", "", "Comma delimited status-name=threshold, same format as --max-load. When status exceeds threshold, app panics and quits")
142
147
flag.Int64Var(&migrationContext.CriticalLoadIntervalMilliseconds, "critical-load-interval-millis", 0, "When 0, migration immediately bails out upon meeting critical-load. When non-zero, a second check is done after given interval, and migration only bails out if 2nd check still meets critical load")
returnthis.migrationContext.Log.Errorf("Found triggers on %s.%s. Triggers are not supported at this time. Bailing out", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
556
+
ifthis.migrationContext.IncludeTriggers {
557
+
this.migrationContext.Log.Infof("Found %d triggers on %s.%s.", numTriggers, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
returnthis.migrationContext.Log.Errorf("Found triggers on %s.%s. Tables with triggers are supported only when using \"include-triggers\" flag. Bailing out", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
557
571
}
558
572
this.migrationContext.Log.Debugf("Validated no triggers exist on table")
559
573
returnnil
560
574
}
561
575
576
+
// verifyTriggersDontExist verifies before createing new triggers we want to make sure these triggers dont exist already in the DB
returnthis.migrationContext.Log.Errorf("Found gh-ost triggers (%s). Please use a different suffix or drop them. Bailing out", strings.Join(foundTriggers, ","))
0 commit comments