zeroes when extracting from binlogs, or DECIMAL
types with non-fractional part > 9 digits may
end up vreplicated as a broken number with
a space.
Signed-off-by: Jacques Grove <aquarapid@gmail.com>
The test code was assuming that configuration had not had a chance
to be reloaded, but sometimes magnetic red shift lead to this happening.
Signed-off-by: Andres Taylor <andres@planetscale.com>
Both when preparing and when executing prepared statements, Vitess
was dropping the connection on most errors. This change makes it
so Vitess instead returns an error packet but keeps the connection open.
Signed-off-by: Andres Taylor <andres@planetscale.com>
When a multistatement query is received, any errors should
abort the execution of the remaining queries.
The `execQuery` and `handleNextCommand` were returning an error,
but not actually using the error value - just checking if it was nil or not.
We need to be able to know on the outside of `execQuery` if an error occured and if it was an error we need to close the connection for or if it was a simple execution error.
Signed-off-by: Andres Taylor <andres@planetscale.com>
* impl+log
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* correctly escape regex
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* simple tests, remove logging
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* years are dumb
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* handle the other tow RE cases.
this is ... mabye a bit much with the factoring out but maybe not
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* fix up comments, move impls around
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* better better error comment <_<
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* assert!
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* to run test suite
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* fix up testsv
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* tests pass; remove dead code-as-comments
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* pull out unnecessary processing
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
* don't differentiate trailing vs leading clarification
Signed-off-by: Richard Bailey <rbailey@slack-corp.com>
caching_sha2_password plugin, unlike mysql_native_password, is a multi
step process. Client hashes the password using SHA2 algorithm and sends
it to the server. Server responds with either an AUTH_MORE_DATA (0x01)
packet or an Error packet.
Error packet is sent when authentication fails during "fast" auth (more
on this below).
The second byte of AUTH_MORE_DATA packet will either be 0x03 or 0x04.
0x03 represents a successful "fast" auth meaning that the server has a
cached hash of the password for the user and it matches the hash sent by
the client. Server will send an OK packet next.
Server sends 0x04 when the hash of the password is not yet cached. In
this case, client has to do a "full" authentication by sending un-hashed
password. If the client is connected using SSL or a Unix socket, client
can write the password in clear text. If this is not the case, client
has to request a public key from the server to encrypt the password.
Client should obfuscate the password using xor operation before
encrypting it with public key and sending it to the server. Server will
respond with an OK packet if autentication is successful or Error packet
otherwise.
Signed-off-by: Vamsi Atluri <vamc19@gmail.com>
During the initial handshake, we are checking if the default auth plugin
of the server is supported by the client. In cases where the server
supports multiple auth plugins, this check is causing the handshake to
fail without giving the server a chance to send an Authentication Method
Switch Request.
This check happens anyway when handling the auth method switch request
and an error is thrown when server requests an unsupported auth method.
Signed-off-by: Vamsi Atluri <vamc19@gmail.com>
* Added a MasterStatus() method and carried it through the entire gRPC
chain, similar to what we do for SlaveStatus(). Other WIP changes to be
updated after getting approval on the MasterStatus() parts.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Small fixes per review suggestions.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Descriptive comments added per review suggestions.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Added unit tests and small fixes.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Refactored per review suggestion. Under new design, it's not possible to unit test anymore, since we don't have mock connections. Removed unit test because of this.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Fix very odd rebase issue I've never seen before, where rebase didn't show me conflicts in various files that it allowed to continue without fixing known conflicts.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Added new MasterStatus return for DemoteMaster and carried it through the entire call chain.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Remove deprecated field everywhere we possibly can, and ensure compatibility for newer client interacting with older server.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Remove copying of XXX fields, per review suggestion.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Added the option to StopReplicationAndGetStatus() to stop only the IO Thread, and passed it all the way down the call chain to MysqlDaemon, where we can now call a new method (implemented in all flavors) which stops only the io thread, if that's what was requested.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Oops
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Remove hook per review suggestion.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Adjusted stop slave io thread to pass in a ctx because it's a new function. Adjusted StopReplicationAndGetStatus so that it stops the slave before getting slave status. This will ensure that the relay log information is correct.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Add back in logic to bail if slave is already stopped.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* We have to patch these in because after calling stop slave there won't be a master host and master port anymore when we grab slave status. Instead we need to patch in positions so we retain master host and master port, otherwise set master will assume the tablet is the master because it has no master host and master port. In retrospect its probably a bad idea that we assume no master host and no master port means we've found the master (in set master).
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Refactored per offline discussions. We now return before and after slave status, so we are more explicit, and don't nest business logic into subfields of a hybrid struct.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Fix issues that cropped up after merge conflict
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Change way we get this state to also pull in the Connecting state. We are either running, or attempting to run. Either way we are not not running.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Changed references from slave to replica per review suggestion.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Embed StopReplicationStatus into StopReplicationAndGetStatusResponse and rename fields to make it clear.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Various fixes per review suggestions.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Lets try out issuing a stop no matter what and see what happens.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Adding back in bailouts. They are necessary.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Get rid of more slave references.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Changed stopIOThreadOnly to an enum so we can change the way in which we stop replication in the future.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Add a test to ensure that we can stop the io thread only.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Fix incorrect test methodology.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Used a generated enum from proto per convention for the stop replication mode.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Scrub more references of slave without obfuscating MySQL statements that are being called under the hood.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
The fakesqldb was waiting .25 seconds on every call to Close.
This speeds up the tabletserver test considerably.
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
- added ability to fetch the GTID from the restore time
- added ability to apply the binlogs till the above GTID
Signed-off-by: Arindam Nayak <arindam.nayak@outlook.com>
This fixes two bugs:
1. AddGTID was mutating the original set. GTIDSet implementations are
supposed to be immutable.
2. AddGTID and parseMariadbGTIDSet did not enforce any order among
domains, yet Equal and other functions expected order to be enforced.
This switches from a list to a map to better represent the fact that the
order of domains doesn't matter, which also simplifies some code.
We always enforce order when serializing back to a string.
Signed-off-by: Anthony Yeh <enisoc@planetscale.com>
* Corrected comment type.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Added Union to the GTIDSet interface
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Wrote Union implementations for all current implementors of GTIDSet interface.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* We need to check if stacks are empty before making comparisons.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Added unit tests for mysql56 and mariadb implementations.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Multiple fixes per review suggestions.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Added helper method for popping intervals so this logic doesn't need to live inside the while loop itself.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Multiple fixes.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Added test to ensure that return from Union is sorted by domain correctly. Also ran formatting.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* We don't need to explicitely non-allocate the second assignment.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Let this panic because supplying nil inputs is an invalid function call.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Comment update per review suggestion.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Add check for receiver being nil but other being non-nil, in case of union always return non-nil set.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Added wrapper struct, modified usage
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Add go.mod
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Refactor dbconfigs and its calls
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Fix failing vstreamer test
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Fix copy and paste mistakes
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Made withCredentials a private function and refactored the calls
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Fix Tests
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Clean up code
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Extend DbConfigs and change method name
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Add Connect Method
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Pass Context as parameter
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Modify definition of DBConfigs
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Make Connect function part of the Connector definition
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
* Remove obselete functions
Signed-off-by: Saif Alharthi <saif@saifalharthi.me>
The mysql server uses buffered I/O. This works fine if the results
are streamed all at once. But if the streaming is intermitent, like
in the case of messages, the client may not get timely responses.
This new change flushes any unsent data if no other data is sent
within mysql_server_flush_delay (100ms).
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
While testing vttablet-mysqld over TCP, we noticed mysql.Connect
sometimes blocks forever if the backend mysqld hit max conns. This
patch adds a timeout to this codepath. It defaults to 0 (no timeout)
for back compatibility.
Signed-off-by: Adam Saponara <as@php.net>
When generating masterGTIDSet in file:pos most likely you will have a topology
like the following:
Source A -> Target B (B has a vreplication stream from A)
From the target perspective, the source A is the master and you want to generate
a gtid that is based on binlog file position of that server.
As an example, let's see this topology:
Master A -> Source B -> Target C (C has vreplication stream from B)
Prior to this change, masterGTIDSet was returning the binlogfile:pos of A. But
in reality, the Target C wants the position of B.
Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
* Prior to this commit, flavorpos was using lexicographical comparison of the gtids.
Thas was a bug in this context.
Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
Azure ignores the mysql_native_password in
the MySQL Login Request packet, and then issues
a Auth Switch Request specifying the mysql_native_password
again, and passing a new salt.
Signed-off-by: Jacques Grove <aquarapid@gmail.com>
Fixes#5532Fixes#5569Fixes#5571
With this fix, unit tests pass for all flavors.
Also fix test.go to cover the newer flavors.
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
* StripChecksum was changing the type of the event. This was a bug.
* Adds test to vstreamer to reflect new support for statement based replication
Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
* Fixed nil bind variables error by resetting bindvars to an empty map. Also added a recover to catch panics that occur inside Logf due to FormatBindVariables call potentially panicking.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Changed import order back. Order was auto-changed by IDE on save
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Using stored ParamsCount for capacity per review suggestion.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Added explanation comment per review suggestion.
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
* Removed explicit panic after offline talk with sougou and deepthi
Signed-off-by: Peter Farr <Peter@PrismaPhonic.com>
The vstreamer sent GTIDs "as they came". With the new change,
GTIDs are sent only when they matter: on COMMIT, DDL or OTHER.
This new approach makes the protocol easier to understand. Also,
it makes it easier for filePos to continuously send file and position.
The correct values will get used when significant events like
COMMIT are encountered.
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
In this scheme, the filePos reader detects whether we are in a
transaction or not, and emits appropriate GTID events.
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
* Fix typo in some comments.
* Make VReplicator private again. This change is no longer needed. Originally we
wanted "vtshovel" to be an external process. Given that this now hooks into the
existent engine, there is no need to make this public.
Signed-off-by: Rafael Chacon <rafael@slack-corp.com>
Fixes#5206
The conn schemaname var can get set through a new connection
or a ComInitDB packet. However, a use statement bypasses this
mechanism and gets handled at the vtgate level. This causes
problems because schemaName in the connection disagrees with
TargetString in vtgate.
To fix this, the new scheme calls a new handler function: ComInitDB
every time schemaName is initialized or changed in the connection.
This way, the TargetString remains the authoritative source
for the current db name.
I couldn't write a test for this specific behavior change because
the mysql go client does not implement support for ComInitDB.
But I've verified the things generally work as expected.
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>