-
Notifications
You must be signed in to change notification settings - Fork 1k
replication,cmd: improve flavor handling #946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package mysql | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func ValidateFlavor(flavor string) error { | ||
switch strings.ToLower(flavor) { | ||
case MySQLFlavor: | ||
return nil | ||
case MariaDBFlavor: | ||
return nil | ||
default: | ||
return fmt.Errorf("%s is not a valid flavor", flavor) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |
"net" | ||
"os" | ||
"strconv" | ||
"strings" | ||
"sync" | ||
"time" | ||
|
||
|
@@ -424,6 +425,18 @@ func (b *BinlogSyncer) GetNextPosition() Position { | |
return b.nextPos | ||
} | ||
|
||
func (b *BinlogSyncer) checkFlavor() { | ||
serverVersion := b.c.GetServerVersion() | ||
if b.cfg.Flavor != MariaDBFlavor && | ||
strings.Contains(b.c.GetServerVersion(), "MariaDB") { | ||
// Setting the flavor to `mysql` causes MariaDB to try and behave | ||
// in a MySQL compatible way. In this mode MariaDB won't use | ||
// MariaDB specific binlog event types, but may used dummy events instead. | ||
b.cfg.Logger.Errorf("misconfigured flavor (%s) for server %s", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And I think we can add comment to explain why this is only a log not a failure to caller, like "MariaDB still sends binlog events in a compatible way although some functionalities are lost, so we just log the problem" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added a code comment. Or did you want to put this in the message instead? |
||
b.cfg.Flavor, serverVersion) | ||
} | ||
} | ||
|
||
// StartSync starts syncing from the `pos` position. | ||
func (b *BinlogSyncer) StartSync(pos Position) (*BinlogStreamer, error) { | ||
b.cfg.Logger.Infof("begin to sync binlog from position %s", pos) | ||
|
@@ -439,6 +452,8 @@ func (b *BinlogSyncer) StartSync(pos Position) (*BinlogStreamer, error) { | |
return nil, errors.Trace(err) | ||
} | ||
|
||
b.checkFlavor() | ||
|
||
return b.startDumpStream(), nil | ||
} | ||
|
||
|
@@ -477,6 +492,8 @@ func (b *BinlogSyncer) StartSyncGTID(gset GTIDSet) (*BinlogStreamer, error) { | |
return nil, err | ||
} | ||
|
||
b.checkFlavor() | ||
|
||
return b.startDumpStream(), nil | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.