[MDEV-8045] Assertion `0' fails in Protocol::end_statement on CREATE VIEW after another connection aborted Created: 2015-04-24  Updated: 2015-05-05  Resolved: 2015-05-05

Status: Closed
Project: MariaDB Server
Component/s: Views
Affects Version/s: 10.0, 10.1
Fix Version/s: 10.0.18, 10.1.5

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: verified


 Description   

10.0/sql/protocol.cc:522: void Protocol::end_statement(): Assertion `0' failed.
150424 18:45:26 [ERROR] mysqld got signal 6 ;
 
#6  0x00007f1cfb0c2311 in *__GI___assert_fail (assertion=0xee5f70 "0", file=<optimized out>, line=522, function=0xee7480 "void Protocol::end_statement()") at assert.c:81
#7  0x00000000005d36ab in Protocol::end_statement (this=0x7f1ce2bf85f8) at 10.0/sql/protocol.cc:522
#8  0x000000000067af47 in dispatch_command (command=COM_QUERY, thd=0x7f1ce2bf8070, packet=0x7f1ce2a18071 "CREATE VIEW v12 AS SELECT 1", packet_length=27) at 10.0/sql/sql_parse.cc:1721
#9  0x0000000000678eaf in do_command (thd=0x7f1ce2bf8070) at 10.0/sql/sql_parse.cc:996
#10 0x00000000007966bf in do_handle_one_connection (thd_arg=0x7f1ce2bf8070) at 10.0/sql/sql_connect.cc:1375
#11 0x0000000000796412 in handle_one_connection (arg=0x7f1ce2bf8070) at 10.0/sql/sql_connect.cc:1289
#12 0x00007f1cfcebcb50 in start_thread (arg=<optimized out>) at pthread_create.c:304
#13 0x00007f1cfb17295d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

Perl testcase

# It assumes the debug server is running on port 3306. 
# All default options are enough
 
use DBD::mysql;
use Carp;
 
my $pid = fork();
 
if ($pid) {
	sleep 1;
	my $dbh = DBI->connect("dbi:mysql:host=127.0.0.1:port=3306:user=root:database=test", undef, undef, { RaiseError => 1 } );
	foreach (1..100) {
		$dbh->do("CREATE OR REPLACE VIEW v AS SELECT 1");
	}
	$dbh->do("shutdown");
	print "All done.\n";
}
elsif ($pid == 0) {
	my $dbh = DBI->connect("dbi:mysql:host=127.0.0.1:port=3306:user=root:database=test", undef, undef, { RaiseError => 1 } );
	sleep 2;
	croak "$$ Aborting now";
}
 
else {
	die "Could not fork";
}

Apparently the problem appeared in 10.0 tree with the following revision:

commit 919443f7a553534de38d40a5cdf50cd3660ace1a
Author: Sergei Golubchik <sergii@pisem.net>
Date:   Mon Jan 19 16:11:48 2015 +0100
 
    MDEV-5679 MariaDB holds stdin open after startup as mysqld
 
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index e0eaf55..7138027 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -5527,6 +5527,7 @@ int mysqld_main(int argc, char **argv)
                          (char*) "" : mysqld_unix_port),
                          mysqld_port,
                          MYSQL_COMPILATION_COMMENT);
+  fclose(stdin);
 #if defined(_WIN32) && !defined(EMBEDDED_LIBRARY)
   Service.SetRunning();
 #endif

Same happens on CREATE TRIGGER.



 Comments   
Comment by Sergei Golubchik [ 2015-05-03 ]

I cannot repeat it in 10.0. Any ideas?

Comment by Elena Stepanova [ 2015-05-03 ]

Perl version maybe? Or system specifics?

I've set it up on perro, current 10.0 branch.
Login as usual.
cd mdev8045
./run.sh

It starts the server on port 8045 and runs the perl script. Output that indicates the problem:

Server command line:
/home/mariadb/mdev8045/10.0/sql/mysqld --no-defaults --basedir=/home/mariadb/mdev8045/10.0 --datadir=/home/mariadb/mdev8045/data --log-error=/home/mariadb/mdev8045/data/log.err --loose-lc-messages-dir=/home/mariadb/mdev8045/10.0/sql/share --port=8045 --socket=/home/mariadb/mdev8045/data/tmp/mysql.sock --tmpdir=/home/mariadb/mdev8045/data/tmp --core-file
...
...
mysqld is alive
 
Now running the test...
55616 Aborting now at /home/mariadb/mdev8045/test.pl line 21
DBD::mysql::db do failed: Lost connection to MySQL server during query at /home/mariadb/mdev8045/test.pl line 13.
DBD::mysql::db do failed: Lost connection to MySQL server during query at /home/mariadb/mdev8045/test.pl line 13.
./run.sh: line 32: 55580 Aborted                 (core dumped) $cmd

Happens every time for me.

Comment by Sergei Golubchik [ 2015-05-03 ]

I've fixed it, but I could not create a deterministic test case that would work on my laptop. elenst, if you'd like to try — go ahead, otherwise I'll just push the fix.

Comment by Elena Stepanova [ 2015-05-03 ]

I already tried very hard and failed before giving up and providing just the ugly perl script – so, please push the fix.

Generated at Thu Feb 08 07:24:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.