Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
e5e619a
default helm vtgate maxReplicas to replicas
Mar 1, 2018
581eab9
dynamically calculate s3 upload partsize for backups
hmcgonig Apr 17, 2018
051b8c5
add support for BIGINT UNSIGNED <--> java.math.BigInteger
Apr 19, 2018
74ce7e2
Move vtcombo initTabletMap func to vtcombo package
arthurnn Apr 19, 2018
e9b0d3b
Add JD.com to the list of adopters
sougou Apr 20, 2018
f3d2e34
Merge remote-tracking branch 'upstream/master' into arthurnn/vtcombo_mv
arthurnn Apr 23, 2018
b9142b3
Fix method name on comment
arthurnn Apr 23, 2018
4398d36
Expose CreateTablet too
arthurnn Apr 23, 2018
987f0c7
Set orchestrator maintenance mode when demoting a master, and disable…
hmcgonig Apr 23, 2018
f241d54
vt/log: Do not use an alias when importing the "glog" package.
michael-berlin Apr 23, 2018
bb0a10f
Merge pull request #3858 from michael-berlin/fix_glog_import
michael-berlin Apr 23, 2018
35fde4c
include the MultiShardAutocommit boolean in the plan json
demmer Apr 23, 2018
17be11d
Adds the possibility to vary the template of tablet debug urls.
mpawliszyn Apr 5, 2018
0d373f4
vt/discovery: Fix import groups in healthcheck files.
michael-berlin Apr 25, 2018
a990225
vt/discovery: Do not export LoadTabletURLTemplate.
michael-berlin Apr 25, 2018
9dd560d
vt/discovery: Check for quotes in template output as well.
michael-berlin Apr 25, 2018
5180793
Merge pull request #3842 from mpawliszyn/mikepaw.format-debug-urls
michael-berlin Apr 25, 2018
8d07774
Merge pull request #3852 from sougou/dox
sougou Apr 26, 2018
a535c6b
stats: Move Counter* and Gauge* types into new file counter.go.
michael-berlin Apr 27, 2018
cac7949
stats: Simplify code for single-value stat variables.
michael-berlin Apr 28, 2018
7a533bf
support parse sql like : DELETE FROM a1, a2 USING t1 AS a1 INNER JOIN…
xhh1989 Apr 28, 2018
fbe5eb4
stats: Fix invalid format string in test.
michael-berlin Apr 28, 2018
56190fa
stats: Reorder calls in test to make them consistent with the other t…
michael-berlin Apr 28, 2018
cd6afec
stats: Split Duration* types into CounterDuration* and GaugeDuration*.
michael-berlin Apr 28, 2018
3b11bce
stats: Reorder code in counters.go.
michael-berlin Apr 28, 2018
a20b453
stats: Rename (Counters|Gauges)WithLabels to *WithSingleLabel.
michael-berlin Apr 28, 2018
8e9d697
stats: CountersWithSingleLabel: Rename "labelName" to "label" to be m…
michael-berlin Apr 28, 2018
66747a1
stats: Change order of "help" parameter in (Gauges|Counters)Func* types.
michael-berlin Apr 28, 2018
2388a9b
stats: Improve counter documentation.
michael-berlin Apr 28, 2018
0bb5994
fix supported data types
jvaidya Apr 28, 2018
17f3ced
Merge pull request #3873 from jvaidya/fix_datatypes
sougou Apr 28, 2018
a6c5e26
stats: Remove CountersFunc type.
michael-berlin Apr 28, 2018
158ee2f
Merge pull request #3867 from michael-berlin/stats_fixes
demmer Apr 30, 2018
2d141ad
removed explanations of RBR vs SBR, we now support RBR
jvaidya Apr 30, 2018
f38ace4
addresed comments
jvaidya Apr 30, 2018
504550e
make the label name customizable for stats.NewTimings
demmer Apr 26, 2018
066e88e
add prometheus support for stats.NewHistogram
demmer Apr 30, 2018
507655b
reorganize all the collector instantiation functions
demmer Apr 30, 2018
fd7b5f8
use a singleton struct instead of a pointer
demmer Apr 30, 2018
cafbca8
include the connection id as part of the mysql conn error logs
demmer May 1, 2018
f86ede1
use "help" uniformly as suggested in PR review
demmer May 1, 2018
86a2728
use Label() instead of LabelName()
demmer May 1, 2018
213d446
remove the unused LabelName() from the Histogram
demmer May 1, 2018
191021c
clean up cutoffs intitialization
demmer May 1, 2018
5dd4aef
fixed link sytax, added pt-osc
jvaidya May 1, 2018
eb92663
Merge pull request #3876 from jvaidya/fix_rbr
sougou May 1, 2018
03943b9
Merge pull request #3880 from tinyspeck/mysql-conn-id-in-error-logs
sougou May 1, 2018
eee2aac
Merge pull request #3847 from HubSpot/jdbc-bigint
sougou May 1, 2018
e86a6f9
Merge pull request #3879 from tinyspeck/prometheus-histogram-improvem…
michael-berlin May 1, 2018
5fc60e4
Merge pull request #3860 from tinyspeck/multi-shard-autocommit-includ…
sougou May 1, 2018
3af24b6
Merge pull request #3859 from HubSpot/reparent_maintenance
sougou May 1, 2018
915888e
Merge pull request #3849 from arthurnn/arthurnn/vtcombo_mv
sougou May 1, 2018
bfafaf3
Merge pull request #3844 from HubSpot/backup_partsize
sougou May 1, 2018
e3e17e0
Merge pull request #3872 from tiglabs/ref_del
sougou May 1, 2018
cce7c61
helm: minor fixes
sougou Apr 29, 2018
a755692
Merge pull request #3875 from sougou/helm
sougou May 2, 2018
9e3189e
Merge pull request #3710 from gflarity/fix_vtgate_helm_tpl
sougou May 2, 2018
0b263a8
Use an alias so goimports doesn't delete a real import
dweitzman May 2, 2018
a3d03d4
Merge pull request #3886 from dweitzman/gofmt
michael-berlin May 2, 2018
d43bb20
change HealthCheckConnections to be a gauge not a counter
demmer May 2, 2018
05ac722
Defend against a potential race condition in registering push stats p…
dweitzman May 4, 2018
0714ddd
Merge pull request #3895 from dweitzman/fix_push_stats_race
michael-berlin May 5, 2018
ba486b3
fix a potential blocking issue when StreamHealth fails
demmer May 5, 2018
494c423
drop the lock in finalizeConn as well before calling Close()
demmer May 6, 2018
5559dac
Merge pull request #3898 from tinyspeck/fix-healthcheck-close-stall
sougou May 6, 2018
2454a7d
Merge pull request #3888 from tinyspeck/minor-prom-fixes
demmer May 6, 2018
a149d8c
Merge remote-tracking branch 'upstream/master' into slack-sync-upstre…
demmer May 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ADOPTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This is an alphabetical list of known adopters of Vitess. Some have already gone
* [BetterCloud](http://bettercloud.com)
* [FlipKart](http://flipkart.com)
* [HubSpot](http://product.hubspot.com/)
* [JD](http://jd.com/)
* [Nozzle](http://nozzle.io)
* [Pixel Federation](http://pixelfederation.com)
* [Quiz of Kings](http://quizofkings.com)
Expand Down
43 changes: 43 additions & 0 deletions data/test/vtgate/dml_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,33 @@
}
}

# insert with multiple rows - multi-shard autocommit
"insert /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ into user(id) values (1), (2)"
{
"Original": "insert /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ into user(id) values (1), (2)",
"Instructions": {
"Opcode": "InsertSharded",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"Query": "insert /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ into user(id, Name, Costly) values (:_Id0, :_Name0, :_Costly0), (:_Id1, :_Name1, :_Costly1)",
"Values": [[[":__seq0",":__seq1"]],[[null,null]],[[null,null]]],
"Table": "user",
"Generate": {
"Keyspace": {
"Name": "main",
"Sharded": false
},
"Query": "select next :n values from seq",
"Values": [1,2]
},
"Prefix": "insert /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ into user(id, Name, Costly) values ",
"Mid": ["(:_Id0, :_Name0, :_Costly0)","(:_Id1, :_Name1, :_Costly1)"],
"MultiShardAutocommit": true
}
}

# simple replace unsharded
"replace into unsharded values(1, 2)"
{
Expand Down Expand Up @@ -1253,6 +1280,22 @@
}
}

# delete from with no index match - multi shard autocommit
"delete /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ from user_extra where name = 'jose'"
{
"Original": "delete /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ from user_extra where name = 'jose'",
"Instructions": {
"Opcode": "DeleteScatter",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"Query": "delete /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ from user_extra where name = 'jose'",
"Table": "user_extra",
"MultiShardAutocommit": true
}
}

# delete from with primary id in through IN clause
"delete from user_extra where user_id in (1, 2)"
{
Expand Down
3 changes: 1 addition & 2 deletions doc/ServerConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ RBR will eventually be supported by Vitess.

### Data types

Vitess supports data types at the MySQL 5.5 level. The newer data types like spatial or JSON are not supported yet. Additionally, the TIMESTAMP data type should not be used in a primary key or sharding column. Otherwise, Vitess cannot predict those values correctly and this may result in data corruption.
Vitess supports all data types including newer data types like spatial and JSON. Additionally, the TIMESTAMP data type should not be used in a primary key or sharding column. Otherwise, Vitess cannot predict those values correctly and this may result in data corruption.

### No side effects

Expand Down Expand Up @@ -676,4 +676,3 @@ Orchestrator, it also means new instances will be discovered immediately,
and the topology will automatically repopulate even if Orchestrator's
backing store is wiped out. Note that Orchestrator will forget stale
instances after a configurable timeout.

72 changes: 9 additions & 63 deletions doc/VitessReplication.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,16 @@
## Statement vs Row Based Replication

MySQL supports two primary modes of replication in its binary logs: statement or
row based.

**Statement Based Replication**:

* The statements executed on the master are copied almost as-is in the master
logs.
* The slaves replay these statements as is.
* If the statements are expensive (especially an update with a complicated WHERE
clause), they will be expensive on the slaves too.
* For current timestamp and auto-increment values, the master also puts
additional SET statements in the logs to make the statement have the same
effect, so the slaves end up with the same values.

**Row Based Replication**:

* The statements executed on the master result in updated rows. The new full
values for these rows are copied to the master logs.
* The slaves change their records for the rows they receive. The update is by
primary key, and contains the new values for each column, so usually it’s very
fast.
* Each updated row contains the entire row, not just the columns that were
updated (unless the flag --binlog\_row\_image=minimal is used).
* The replication stream is harder to read, as it contains almost binary data,
that don’t easily map to the original statements.
* There is a configurable limit on how many rows can be affected by one
binlog event, so the master logs are not flooded.
* The format of the logs depends on the master schema: each row has a list of
values, one value for each column. So if the master schema is different from
the slave schema, updates will misbehave (exception being if slave has extra
columns at the end).
* It is possible to revert to statement based replication for some commands to
avoid these drawbacks (for instance for DELETE statements that affect a large
number of rows).
* Schema changes always use statement based replication.
* If comments are added to a statement, they are stripped from the
replication stream (as only rows are transmitted). There is a flag
--binlog\_rows\_query\_log\_events to add the original statement to each row
update, but it is costly in terms of binlog size.

For the longest time, MySQL replication has been single-threaded: only one
statement is applied by the slaves at a time. Since the master applies more
statements in parallel, replication can fall behind on the slaves fairly easily,
under higher load. Even though the situation has improved (parallel slave
apply), the slave replication speed is still a limiting factor for a lot of
applications. Since row based replication achieves higher update rates on the
slaves in most cases, it has been the only viable option for most performance
sensitive applications.

Schema changes however are not easy to achieve with row based
replication. Adding columns can be done offline, but removing or changing
columns cannot easily be done (there are multiple ways to achieve this, but they
all have limitations or performance implications, and are not that easy to
setup).

Vitess helps by using statement based replication (therefore allowing complex
schema changes), while at the same time simplifying the replication stream (so
slaves can be fast), by rewriting Update statements.

Then, with statement based replication, it becomes easier to perform offline
advanced schema changes, or large data updates. Vitess’s solution is called
schema swap.
row based. Vitess supports both these modes.

For schema changes, if the number of affected rows is greater > 100k (configurable), we don't allow direct application
of DDLs. The recommended tools in such cases are [gh-ost](https://github.com/github/gh-ost) or [pt-osc](https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html).

We plan to also support row based replication in the future, and adapt our tools
to provide the same features when possible. See Appendix for our plan.
Not all statements are safe for Statement Based Replication (SBR): https://dev.mysql.com/doc/refman/8.0/en/replication-rbr-safe-unsafe.html. Vitess rewrites some of these statements to be safe for SBR, and others are explicitly failed. This is described in detail below.

With statement based replication, it becomes easier to perform offline
advanced schema changes, or large data updates. Vitess’s solution is called
schema swap (described below).

## Rewriting Update Statements

Expand Down
3 changes: 2 additions & 1 deletion go/cmd/vtcombo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"vitess.io/vitess/go/vt/srvtopo"
"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/topo/memorytopo"
"vitess.io/vitess/go/vt/vtcombo"
"vitess.io/vitess/go/vt/vtctld"
"vitess.io/vitess/go/vt/vtgate"
"vitess.io/vitess/go/vt/vttablet/tabletserver/tabletenv"
Expand Down Expand Up @@ -109,7 +110,7 @@ func main() {
servenv.OnClose(mysqld.Close)

// tablets configuration and init
if err := initTabletMap(ts, tpb, mysqld, *dbcfgs, *schemaDir, mycnf); err != nil {
if err := vtcombo.InitTabletMap(ts, tpb, mysqld, *dbcfgs, *schemaDir, mycnf); err != nil {
log.Errorf("initTabletMapProto failed: %v", err)
exit.Return(1)
}
Expand Down
14 changes: 7 additions & 7 deletions go/mysql/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,31 +579,31 @@ func (c *Conn) writeEphemeralPacket(direct bool) error {
// Just write c.buffer as a single buffer.
// It has both header and data.
if n, err := w.Write(c.buffer); err != nil {
return fmt.Errorf("Write(c.buffer) failed: %v", err)
return fmt.Errorf("Conn %v: Write(c.buffer) failed: %v", c.ID(), err)
} else if n != len(c.buffer) {
return fmt.Errorf("Write(c.buffer) returned a short write: %v < %v", n, len(c.buffer))
return fmt.Errorf("Conn %v: Write(c.buffer) returned a short write: %v < %v", c.ID(), n, len(c.buffer))
}
case ephemeralWriteSingleBuffer:
// Write the allocated buffer as a single buffer.
// It has both header and data.
if n, err := w.Write(c.currentEphemeralPacket); err != nil {
return fmt.Errorf("Write(c.currentEphemeralPacket) failed: %v", err)
return fmt.Errorf("Conn %v: Write(c.currentEphemeralPacket) failed: %v", c.ID(), err)
} else if n != len(c.currentEphemeralPacket) {
return fmt.Errorf("Write(c.currentEphemeralPacket) returned a short write: %v < %v", n, len(c.currentEphemeralPacket))
return fmt.Errorf("Conn %v: Write(c.currentEphemeralPacket) returned a short write: %v < %v", c.ID(), n, len(c.currentEphemeralPacket))
}
case ephemeralWriteBigBuffer:
// This is the slower path for big data.
// With direct=true, the caller expects a flush, so we call it
// manually.
if err := c.writePacket(c.currentEphemeralPacket); err != nil {
return err
return fmt.Errorf("Conn %v: %v", c.ID(), err)
}
if direct {
return c.flush()
}
case ephemeralUnused, ephemeralReadGlobalBuffer, ephemeralReadSingleBuffer, ephemeralReadBigBuffer:
// Programming error.
panic(fmt.Errorf("trying to call writeEphemeralPacket while currentEphemeralPolicy is %v", c.currentEphemeralPolicy))
panic(fmt.Errorf("Conn %v: trying to call writeEphemeralPacket while currentEphemeralPolicy is %v", c.ID(), c.currentEphemeralPolicy))
}

return nil
Expand All @@ -613,7 +613,7 @@ func (c *Conn) writeEphemeralPacket(direct bool) error {
// This method returns a generic error, not a SQLError.
func (c *Conn) flush() error {
if err := c.writer.Flush(); err != nil {
return fmt.Errorf("Flush() failed: %v", err)
return fmt.Errorf("Conn %v: Flush() failed: %v", c.ID(), err)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion go/mysql/ldapauthserver/auth_server_ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"sync"
"time"

"gopkg.in/ldap.v2"
ldap "gopkg.in/ldap.v2"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/netutil"
"vitess.io/vitess/go/vt/log"
Expand Down
2 changes: 1 addition & 1 deletion go/mysql/ldapauthserver/auth_server_ldap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"
"testing"

"gopkg.in/ldap.v2"
ldap "gopkg.in/ldap.v2"
)

type MockLdapClient struct{}
Expand Down
2 changes: 1 addition & 1 deletion go/mysql/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (

var (
// Metrics
timings = stats.NewTimings("MysqlServerTimings", "MySQL server timings")
timings = stats.NewTimings("MysqlServerTimings", "MySQL server timings", "operation")
connCount = stats.NewGauge("MysqlServerConnCount", "Active MySQL server connections")
connAccept = stats.NewCounter("MysqlServerConnAccepted", "Connections accepted by MySQL server")
connSlow = stats.NewCounter("MysqlServerConnSlow", "Connections that took more than the configured mysql_slow_connect_warn_threshold to establish")
Expand Down
Loading