Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions config/mycnf/master_mysql56.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ log_bin
log_slave_updates
enforce_gtid_consistency

# Ignore relay logs on disk at startup.
relay_log_recovery
# Crash-safe replication settings.
master_info_repository = TABLE
relay_log_info_repository = TABLE
relay_log_purge = 1
relay_log_recovery = 1

# Native AIO tends to run into aio-max-nr limit during test startup.
innodb_use_native_aio = 0
6 changes: 6 additions & 0 deletions go/vt/vtgate/buffer/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,12 @@ func TestWindow(t *testing.T) {
// (queue becomes not empty a second time).
flag.Set("buffer_window", "10m")

// This is a hack. The buffering semaphore gets released asynchronously.
// Sometimes the next issueRequest tries to acquire before that release
// and ends up failing. Waiting for the previous goroutines to exit ensures
// that the sema will get released.
b.waitForShutdown()

// This time the request does not go out of window and gets evicted by a third
// request instead.
t.Logf("second request does not exceed its window")
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/endtoend/compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestCharaterSet(t *testing.T) {
OrgTable: "vitess_test",
Database: "vttest",
OrgName: "charval",
ColumnLength: 768,
ColumnLength: 30,
Charset: 33,
}, {
Name: "binval",
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/endtoend/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func initTableACL() error {
return nil
}

var testSchema = `create table vitess_test(intval int default 0, floatval float default null, charval varchar(256) default null, binval varbinary(256) default null, primary key(intval));
var testSchema = `create table vitess_test(intval int default 0, floatval float default null, charval varchar(10) default null, binval varbinary(256) default null, primary key(intval));
create table vitess_test_debuguser(intval int default 0, floatval float default null, charval varchar(256) default null, binval varbinary(256) default null, primary key(intval));
grant select, show databases, process on *.* to 'vt_appdebug'@'localhost';
revoke select on *.* from 'vt_appdebug'@'localhost';
Expand Down
30 changes: 15 additions & 15 deletions go/vt/vttablet/endtoend/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,56 +605,56 @@ func TestLogTruncation(t *testing.T) {

// Test that a long error string is not truncated by default
_, err := client.Execute(
"insert into vitess_test values(123, :data, null, null)",
"insert into vitess_test values(123, null, :data, null)",
map[string]*querypb.BindVariable{"data": sqltypes.StringBindVariable("THIS IS A LONG LONG LONG LONG QUERY STRING THAT SHOULD BE SHORTENED")},
)
wantLog := "Data truncated for column 'floatval' at row 1 (errno 1265) (sqlstate 01000) (CallerID: dev): Sql: \"insert into vitess_test values(123, :data, null, null)\", BindVars: {#maxLimit: \"type:INT64 value:\\\"10001\\\" \"data: \"type:VARCHAR value:\\\"THIS IS A LONG LONG LONG LONG QUERY STRING THAT SHOULD BE SHORTENED\\\" \"}"
wantErr := "Data truncated for column 'floatval' at row 1 (errno 1265) (sqlstate 01000) (CallerID: dev): Sql: \"insert into vitess_test values(123, :data, null, null)\", BindVars: {#maxLimit: \"type:INT64 value:\\\"10001\\\" \"data: \"type:VARCHAR value:\\\"THIS IS A LONG LONG LONG LONG QUERY STRING THAT SHOULD BE SHORTENED\\\" \"}"
wantLog := `Data too long for column 'charval' at row 1 (errno 1406) (sqlstate 22001) (CallerID: dev): Sql: "insert into vitess_test values(123, null, :data, null)", BindVars: {#maxLimit: "type:INT64 value:\"10001\" "data: "type:VARCHAR value:\"THIS IS A LONG LONG LONG LONG QUERY STRING THAT SHOULD BE SHORTENED\" "}`
wantErr := wantLog
if err == nil {
t.Errorf("query unexpectedly succeeded")
}
if getTestLog(0) != wantLog {
t.Errorf("log was unexpectedly truncated: got '%s', want '%s'", getTestLog(0), wantLog)
t.Errorf("log was unexpectedly truncated: got\n'%s', want\n'%s'", getTestLog(0), wantLog)
}

if err.Error() != wantErr {
t.Errorf("error was unexpectedly truncated: got '%s', want '%s'", err.Error(), wantErr)
t.Errorf("error was unexpectedly truncated: got\n'%s', want\n'%s'", err.Error(), wantErr)
}

// Test that the data too long error is truncated once the option is set
*sqlparser.TruncateErrLen = 30
_, err = client.Execute(
"insert into vitess_test values(123, :data, null, null)",
"insert into vitess_test values(123, null, :data, null)",
map[string]*querypb.BindVariable{"data": sqltypes.StringBindVariable("THIS IS A LONG LONG LONG LONG QUERY STRING THAT SHOULD BE SHORTENED")},
)
wantLog = "Data truncated for column 'floatval' at row 1 (errno 1265) (sqlstate 01000) (CallerID: dev): Sql: \"insert into vitess [TRUNCATED]\", BindVars: {#maxLim [TRUNCATED]"
wantErr = "Data truncated for column 'floatval' at row 1 (errno 1265) (sqlstate 01000) (CallerID: dev): Sql: \"insert into vitess_test values(123, :data, null, null)\", BindVars: {#maxLimit: \"type:INT64 value:\\\"10001\\\" \"data: \"type:VARCHAR value:\\\"THIS IS A LONG LONG LONG LONG QUERY STRING THAT SHOULD BE SHORTENED\\\" \"}"
wantLog = `Data too long for column 'charval' at row 1 (errno 1406) (sqlstate 22001) (CallerID: dev): Sql: "insert into vitess [TRUNCATED]", BindVars: {#maxLim [TRUNCATED]`
wantErr = `Data too long for column 'charval' at row 1 (errno 1406) (sqlstate 22001) (CallerID: dev): Sql: "insert into vitess_test values(123, null, :data, null)", BindVars: {#maxLimit: "type:INT64 value:\"10001\" "data: "type:VARCHAR value:\"THIS IS A LONG LONG LONG LONG QUERY STRING THAT SHOULD BE SHORTENED\" "}`
if err == nil {
t.Errorf("query unexpectedly succeeded")
}
if getTestLog(1) != wantLog {
t.Errorf("log was not truncated properly: got '%s', want '%s'", getTestLog(1), wantLog)
t.Errorf("log was not truncated properly: got\n'%s', want\n'%s'", getTestLog(1), wantLog)
}
if err.Error() != wantErr {
t.Errorf("error was unexpectedly truncated: got '%s', want '%s'", err.Error(), wantErr)
t.Errorf("error was unexpectedly truncated: got\n'%s', want\n'%s'", err.Error(), wantErr)
}

// Test that trailing comments are preserved data too long error is truncated once the option is set
*sqlparser.TruncateErrLen = 30
_, err = client.Execute(
"insert into vitess_test values(123, :data, null, null) /* KEEP ME */",
"insert into vitess_test values(123, null, :data, null) /* KEEP ME */",
map[string]*querypb.BindVariable{"data": sqltypes.StringBindVariable("THIS IS A LONG LONG LONG LONG QUERY STRING THAT SHOULD BE SHORTENED")},
)
wantLog = "Data truncated for column 'floatval' at row 1 (errno 1265) (sqlstate 01000) (CallerID: dev): Sql: \"insert into vitess [TRUNCATED] /* KEEP ME */\", BindVars: {#maxLim [TRUNCATED]"
wantErr = "Data truncated for column 'floatval' at row 1 (errno 1265) (sqlstate 01000) (CallerID: dev): Sql: \"insert into vitess_test values(123, :data, null, null) /* KEEP ME */\", BindVars: {#maxLimit: \"type:INT64 value:\\\"10001\\\" \"data: \"type:VARCHAR value:\\\"THIS IS A LONG LONG LONG LONG QUERY STRING THAT SHOULD BE SHORTENED\\\" \"}"
wantLog = `Data too long for column 'charval' at row 1 (errno 1406) (sqlstate 22001) (CallerID: dev): Sql: "insert into vitess [TRUNCATED] /* KEEP ME */", BindVars: {#maxLim [TRUNCATED]`
wantErr = `Data too long for column 'charval' at row 1 (errno 1406) (sqlstate 22001) (CallerID: dev): Sql: "insert into vitess_test values(123, null, :data, null) /* KEEP ME */", BindVars: {#maxLimit: "type:INT64 value:\"10001\" "data: "type:VARCHAR value:\"THIS IS A LONG LONG LONG LONG QUERY STRING THAT SHOULD BE SHORTENED\" "}`
if err == nil {
t.Errorf("query unexpectedly succeeded")
}
if getTestLog(2) != wantLog {
t.Errorf("log was not truncated properly: got '%s', want '%s'", getTestLog(2), wantLog)
t.Errorf("log was not truncated properly: got\n'%s', want\n'%s'", getTestLog(2), wantLog)
}
if err.Error() != wantErr {
t.Errorf("error was unexpectedly truncated: got '%s', want '%s'", err.Error(), wantErr)
t.Errorf("error was unexpectedly truncated: got\n'%s', want\n'%s'", err.Error(), wantErr)
}
}

Expand Down
22 changes: 16 additions & 6 deletions test/update_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,18 @@ def test_event_token(self):
'EventTokenPosition must be up to date but got %s (expected %s)' %
(value, replica_position), timeout)

# Replica position can still move forward after this when things are slow.
# Compare only server ids.
replica_position = replica_position.split(":")[0]

# With vttablet up to date, test a vttablet query returns the EventToken.
qr = replica_tablet.execute('select * from vt_insert_test',
execute_options='include_event_token:true ')
logging.debug('Got result: %s', qr)
self.assertIn('extras', qr)
self.assertIn('event_token', qr['extras'])
self.assertEqual(qr['extras']['event_token']['position'], replica_position)
pos = qr['extras']['event_token']['position'].split(":")[0]
self.assertEqual(pos, replica_position)

# Same thing through vtgate
qr = utils.vtgate.execute('select * from vt_insert_test',
Expand All @@ -398,7 +403,8 @@ def test_event_token(self):
logging.debug('Got result: %s', qr)
self.assertIn('extras', qr)
self.assertIn('event_token', qr['extras'])
self.assertEqual(qr['extras']['event_token']['position'], replica_position)
pos = qr['extras']['event_token']['position'].split(":")[0]
self.assertEqual(pos, replica_position)

# Make sure the compare_event_token flag works, by sending a very
# old timestamp, or a timestamp in the future.
Expand Down Expand Up @@ -441,7 +447,8 @@ def test_event_token(self):
self.assertIn('fresher', qr['extras'])
self.assertTrue(qr['extras']['fresher'])
self.assertIn('event_token', qr['extras'])
self.assertEqual(qr['extras']['event_token']['position'], replica_position)
pos = qr['extras']['event_token']['position'].split(":")[0]
self.assertEqual(pos, replica_position)

future_timestamp = long(time.time()) + 100
qr = replica_tablet.execute('select * from vt_insert_test',
Expand All @@ -450,7 +457,8 @@ def test_event_token(self):
future_timestamp)
self.assertNotIn('fresher', qr['extras'])
self.assertIn('event_token', qr['extras'])
self.assertEqual(qr['extras']['event_token']['position'], replica_position)
pos = qr['extras']['event_token']['position'].split(":")[0]
self.assertEqual(pos, replica_position)

# Same thing through vtgate
qr = utils.vtgate.execute('select * from vt_insert_test',
Expand All @@ -461,7 +469,8 @@ def test_event_token(self):
self.assertIn('fresher', qr['extras'])
self.assertTrue(qr['extras']['fresher'])
self.assertIn('event_token', qr['extras'])
self.assertEqual(qr['extras']['event_token']['position'], replica_position)
pos = qr['extras']['event_token']['position'].split(":")[0]
self.assertEqual(pos, replica_position)

future_timestamp = long(time.time()) + 100
qr = utils.vtgate.execute('select * from vt_insert_test',
Expand All @@ -471,7 +480,8 @@ def test_event_token(self):
future_timestamp)
self.assertNotIn('fresher', qr['extras'])
self.assertIn('event_token', qr['extras'])
self.assertEqual(qr['extras']['event_token']['position'], replica_position)
pos = qr['extras']['event_token']['position'].split(":")[0]
self.assertEqual(pos, replica_position)

def test_update_stream_interrupt(self):
"""Checks that a running query is terminated on going non-serving."""
Expand Down