diff --git a/config/mycnf/master_mysql56.cnf b/config/mycnf/master_mysql56.cnf index 91323c8fbc2..2934975d751 100644 --- a/config/mycnf/master_mysql56.cnf +++ b/config/mycnf/master_mysql56.cnf @@ -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 diff --git a/go/vt/vtgate/buffer/buffer_test.go b/go/vt/vtgate/buffer/buffer_test.go index ee94dd52010..b42ed617669 100644 --- a/go/vt/vtgate/buffer/buffer_test.go +++ b/go/vt/vtgate/buffer/buffer_test.go @@ -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") diff --git a/go/vt/vttablet/endtoend/compatibility_test.go b/go/vt/vttablet/endtoend/compatibility_test.go index 4a30599bf0e..6edc6628e4b 100644 --- a/go/vt/vttablet/endtoend/compatibility_test.go +++ b/go/vt/vttablet/endtoend/compatibility_test.go @@ -63,7 +63,7 @@ func TestCharaterSet(t *testing.T) { OrgTable: "vitess_test", Database: "vttest", OrgName: "charval", - ColumnLength: 768, + ColumnLength: 30, Charset: 33, }, { Name: "binval", diff --git a/go/vt/vttablet/endtoend/main_test.go b/go/vt/vttablet/endtoend/main_test.go index 67f03b8e597..f341d8fba36 100644 --- a/go/vt/vttablet/endtoend/main_test.go +++ b/go/vt/vttablet/endtoend/main_test.go @@ -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'; diff --git a/go/vt/vttablet/endtoend/misc_test.go b/go/vt/vttablet/endtoend/misc_test.go index 0b7368cebb1..5e961a9ae32 100644 --- a/go/vt/vttablet/endtoend/misc_test.go +++ b/go/vt/vttablet/endtoend/misc_test.go @@ -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) } } diff --git a/test/update_stream.py b/test/update_stream.py index 97f3059cadf..035a3dcd9d6 100755 --- a/test/update_stream.py +++ b/test/update_stream.py @@ -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', @@ -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. @@ -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', @@ -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', @@ -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', @@ -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."""