You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

587 lines
17 KiB

Backport of revno: 2617.68.18 Bug #42147 Concurrent DML and LOCK TABLE ... READ for InnoDB table cause warnings in errlog Concurrent execution of LOCK TABLES ... READ statement and DML statements affecting the same InnoDB table on debug builds of MySQL server might lead to "Found lock of type 6 that is write and read locked" warnings appearing in error log. The problem is that the table-level locking code allows a thread to acquire TL_READ_NO_INSERT lock on a table even if there is another thread which holds TL_WRITE_ALLOW_WRITE lock on the same table. At the same time, the locking code assumes that that such locks are incompatible (for example, see check_locks()). This doesn't lead to any problems other than warnings in error log for debug builds of server since for InnoDB tables TL_READ_NO_INSERT type of lock is only used for LOCK TABLES and for this statement InnoDB also performs its own table-level locking. Unfortunately, the table lock compatibility matrix cannot be updated to disallow TL_READ_NO_INSERT when another thread holds TL_WRITE_ALLOW_WRITE without causing starvation of LOCK TABLE READ in InnoDB under high write load. This patch therefore contains no code changes. The issue will be fixed later when LOCK TABLE READ has been updated to not use table locks. This bug will therefore be marked as "To be fixed later". Code comment in thr_lock.c expanded to clarify the issue and a test case based on the bug description added to innodb_mysql_lock.test. Note that a global suppression rule has been added to both MTR v1 and v2 for the "Found lock of type 6 that is write and read locked" warning. These suppression rules must be removed once this bug is properly fixed.
16 years ago
  1. # -*- cperl -*-
  2. # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; version 2 of the License.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. # This is a library file used by the Perl version of mysql-test-run,
  17. # and is part of the translation of the Bourne shell script with the
  18. # same name.
  19. use strict;
  20. use warnings;
  21. sub mtr_report_test_name($);
  22. sub mtr_report_test_passed($);
  23. sub mtr_report_test_failed($);
  24. sub mtr_report_test_skipped($);
  25. sub mtr_report_test_not_skipped_though_disabled($);
  26. sub mtr_report_stats ($);
  27. sub mtr_print_line ();
  28. sub mtr_print_thick_line ();
  29. sub mtr_print_header ();
  30. sub mtr_report (@);
  31. sub mtr_warning (@);
  32. sub mtr_error (@);
  33. sub mtr_child_error (@);
  34. sub mtr_debug (@);
  35. sub mtr_verbose (@);
  36. my $tot_real_time= 0;
  37. ##############################################################################
  38. #
  39. #
  40. #
  41. ##############################################################################
  42. sub mtr_report_test_name ($) {
  43. my $tinfo= shift;
  44. my $tname= $tinfo->{name};
  45. $tname.= " '$tinfo->{combination}'"
  46. if defined $tinfo->{combination};
  47. _mtr_log($tname);
  48. printf "%-30s ", $tname;
  49. }
  50. sub mtr_report_test_skipped ($) {
  51. my $tinfo= shift;
  52. $tinfo->{'result'}= 'MTR_RES_SKIPPED';
  53. if ( $tinfo->{'disable'} )
  54. {
  55. mtr_report("[ disabled ] $tinfo->{'comment'}");
  56. }
  57. elsif ( $tinfo->{'comment'} )
  58. {
  59. mtr_report("[ skipped ] $tinfo->{'comment'}");
  60. }
  61. else
  62. {
  63. mtr_report("[ skipped ]");
  64. }
  65. }
  66. sub mtr_report_tests_not_skipped_though_disabled ($) {
  67. my $tests= shift;
  68. if ( $::opt_enable_disabled )
  69. {
  70. my @disabled_tests= grep {$_->{'dont_skip_though_disabled'}} @$tests;
  71. if ( @disabled_tests )
  72. {
  73. print "\nTest(s) which will be run though they are marked as disabled:\n";
  74. foreach my $tinfo ( sort {$a->{'name'} cmp $b->{'name'}} @disabled_tests )
  75. {
  76. printf " %-20s : %s\n", $tinfo->{'name'}, $tinfo->{'comment'};
  77. }
  78. }
  79. }
  80. }
  81. sub mtr_report_test_passed ($) {
  82. my $tinfo= shift;
  83. my $timer= "";
  84. if ( $::opt_timer and -f "$::opt_vardir/log/timer" )
  85. {
  86. $timer= mtr_fromfile("$::opt_vardir/log/timer");
  87. $tot_real_time += ($timer/1000);
  88. $timer= sprintf "%12s", $timer;
  89. }
  90. $tinfo->{'result'}= 'MTR_RES_PASSED';
  91. mtr_report("[ pass ] $timer");
  92. }
  93. sub mtr_report_test_failed ($) {
  94. my $tinfo= shift;
  95. $tinfo->{'result'}= 'MTR_RES_FAILED';
  96. if ( defined $tinfo->{'timeout'} )
  97. {
  98. mtr_report("[ fail ] timeout");
  99. return;
  100. }
  101. else
  102. {
  103. mtr_report("[ fail ]");
  104. }
  105. if ( $tinfo->{'comment'} )
  106. {
  107. # The test failure has been detected by mysql-test-run.pl
  108. # when starting the servers or due to other error, the reason for
  109. # failing the test is saved in "comment"
  110. mtr_report("\nERROR: $tinfo->{'comment'}");
  111. }
  112. elsif ( -f $::path_timefile )
  113. {
  114. # Test failure was detected by test tool and it's report
  115. # about what failed has been saved to file. Display the report.
  116. print "\n";
  117. print mtr_fromfile($::path_timefile); # FIXME print_file() instead
  118. print "\n";
  119. }
  120. else
  121. {
  122. # Neither this script or the test tool has recorded info
  123. # about why the test has failed. Should be debugged.
  124. mtr_report("\nUnexpected termination, probably when starting mysqld");;
  125. }
  126. }
  127. sub mtr_report_stats ($) {
  128. my $tests= shift;
  129. # ----------------------------------------------------------------------
  130. # Find out how we where doing
  131. # ----------------------------------------------------------------------
  132. my $tot_skiped= 0;
  133. my $tot_passed= 0;
  134. my $tot_failed= 0;
  135. my $tot_tests= 0;
  136. my $tot_restarts= 0;
  137. my $found_problems= 0; # Some warnings in the logfiles are errors...
  138. foreach my $tinfo (@$tests)
  139. {
  140. if ( $tinfo->{'result'} eq 'MTR_RES_SKIPPED' )
  141. {
  142. $tot_skiped++;
  143. }
  144. elsif ( $tinfo->{'result'} eq 'MTR_RES_PASSED' )
  145. {
  146. $tot_tests++;
  147. $tot_passed++;
  148. }
  149. elsif ( $tinfo->{'result'} eq 'MTR_RES_FAILED' )
  150. {
  151. $tot_tests++;
  152. $tot_failed++;
  153. }
  154. if ( $tinfo->{'restarted'} )
  155. {
  156. $tot_restarts++;
  157. }
  158. }
  159. # ----------------------------------------------------------------------
  160. # Print out a summary report to screen
  161. # ----------------------------------------------------------------------
  162. if ( ! $tot_failed )
  163. {
  164. print "All $tot_tests tests were successful.\n";
  165. }
  166. else
  167. {
  168. my $ratio= $tot_passed * 100 / $tot_tests;
  169. print "Failed $tot_failed/$tot_tests tests, ";
  170. printf("%.2f", $ratio);
  171. print "\% were successful.\n\n";
  172. print
  173. "The log files in var/log may give you some hint\n",
  174. "of what went wrong.\n",
  175. "If you want to report this error, please read first ",
  176. "the documentation at\n",
  177. "http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html\n";
  178. }
  179. if (!$::opt_extern)
  180. {
  181. print "The servers were restarted $tot_restarts times\n";
  182. }
  183. if ( $::opt_timer )
  184. {
  185. use English;
  186. mtr_report("Spent", sprintf("%.3f", $tot_real_time),"of",
  187. time - $BASETIME, "seconds executing testcases");
  188. }
  189. # ----------------------------------------------------------------------
  190. # If a debug run, there might be interesting information inside
  191. # the "var/log/*.err" files. We save this info in "var/log/warnings"
  192. # ----------------------------------------------------------------------
  193. if ( ! $::glob_use_running_server )
  194. {
  195. # Save and report if there was any fatal warnings/errors in err logs
  196. my $warnlog= "$::opt_vardir/log/warnings";
  197. unless ( open(WARN, ">$warnlog") )
  198. {
  199. mtr_warning("can't write to the file \"$warnlog\": $!");
  200. }
  201. else
  202. {
  203. # We report different types of problems in order
  204. foreach my $pattern ( "^Warning:",
  205. "\\[Warning\\]",
  206. "\\[ERROR\\]",
  207. "^Error:", "^==.* at 0x",
  208. "InnoDB: Warning",
  209. "InnoDB: Error",
  210. "^safe_mutex:",
  211. "missing DBUG_RETURN",
  212. "mysqld: Warning",
  213. "allocated at line",
  214. "Attempting backtrace", "Assertion .* failed" )
  215. {
  216. foreach my $errlog ( sort glob("$::opt_vardir/log/*.err") )
  217. {
  218. my $testname= "";
  219. unless ( open(ERR, $errlog) )
  220. {
  221. mtr_warning("can't read $errlog");
  222. next;
  223. }
  224. while ( <ERR> )
  225. {
  226. # Skip some non fatal warnings from the log files
  227. if (
  228. /\"SELECT UNIX_TIMESTAMP\(\)\" failed on master/ or
  229. /Aborted connection/ or
  230. /Client requested master to start replication from impossible position/ or
  231. /Could not find first log file name in binary log/ or
  232. /Enabling keys got errno/ or
  233. /Error reading master configuration/ or
  234. /Error reading packet/ or
  235. /Event Scheduler/ or
  236. /Failed to open log/ or
  237. /Failed to open the existing master info file/ or
  238. /Forcing shutdown of [0-9]* plugins/ or
  239. /Can't open shared library .*\bha_example\b/ or
  240. /Couldn't load plugin .*\bha_example\b/ or
  241. # Due to timing issues, it might be that this warning
  242. # is printed when the server shuts down and the
  243. # computer is loaded.
  244. /Forcing close of thread \d+ user: '.*?'/ or
  245. /Got error [0-9]* when reading table/ or
  246. /Incorrect definition of table/ or
  247. /Incorrect information in file/ or
  248. /InnoDB: Warning: we did not need to do crash recovery/ or
  249. /Invalid \(old\?\) table or database name/ or
  250. /Lock wait timeout exceeded/ or
  251. /Log entry on master is longer than max_allowed_packet/ or
  252. /unknown option '--loose-/ or
  253. /unknown variable 'loose-/ or
  254. /You have forced lower_case_table_names to 0 through a command-line option/ or
  255. /Setting lower_case_table_names=2/ or
  256. /NDB Binlog:/ or
  257. /NDB: failed to setup table/ or
  258. /NDB: only row based binary logging/ or
  259. /Neither --relay-log nor --relay-log-index were used/ or
  260. /Query partially completed/ or
  261. /Slave I.O thread aborted while waiting for relay log/ or
  262. /Slave SQL thread is stopped because UNTIL condition/ or
  263. /Slave SQL thread retried transaction/ or
  264. /Slave \(additional info\)/ or
  265. /Slave: .*Duplicate column name/ or
  266. /Slave: .*master may suffer from/ or
  267. /Slave: According to the master's version/ or
  268. /Slave: Column [0-9]* type mismatch/ or
  269. /Slave: Error .* doesn't exist/ or
  270. /Slave: Deadlock found/ or
  271. /Slave: Error .*Unknown table/ or
  272. /Slave: Error in Write_rows event: / or
  273. /Slave: Field .* of table .* has no default value/ or
  274. /Slave: Field .* doesn't have a default value/ or
  275. /Slave: Query caused different errors on master and slave/ or
  276. /Slave: Table .* doesn't exist/ or
  277. /Slave: Table width mismatch/ or
  278. /Slave: The incident LOST_EVENTS occured on the master/ or
  279. /Slave: Unknown error.* 1105/ or
  280. /Slave: Can't drop database.* database doesn't exist/ or
  281. /Slave SQL:.*(?:Error_code: \d+|Query:.*)/ or
  282. /Sort aborted/ or
  283. /Time-out in NDB/ or
  284. /One can only use the --user.*root/ or
  285. /Table:.* on (delete|rename)/ or
  286. /You have an error in your SQL syntax/ or
  287. /deprecated/ or
  288. /description of time zone/ or
  289. /equal MySQL server ids/ or
  290. /error .*connecting to master/ or
  291. /error reading log entry/ or
  292. /lower_case_table_names is set/ or
  293. /skip-name-resolve mode/ or
  294. /slave SQL thread aborted/ or
  295. /Slave: .*Duplicate entry/ or
  296. # Special case for Bug #26402 in show_check.test
  297. # Question marks are not valid file name parts
  298. # on Windows platforms. Ignore this error message.
  299. /\QCan't find file: '.\test\????????.frm'\E/ or
  300. # Special case, made as specific as possible, for:
  301. # Bug #28436: Incorrect position in SHOW BINLOG EVENTS causes
  302. # server coredump
  303. /\QError in Log_event::read_log_event(): 'Sanity check failed', data_len: 258, event_type: 49\E/ or
  304. /Statement is not safe to log in statement format/ or
  305. # test case for Bug#bug29807 copies a stray frm into database
  306. /InnoDB: Error: table `test`.`bug29807` does not exist in the InnoDB internal/ or
  307. /Cannot find or open table test\/bug29807 from/ or
  308. # innodb foreign key tests that fail in ALTER or RENAME produce this
  309. /InnoDB: Error: in ALTER TABLE `test`.`t[12]`/ or
  310. /InnoDB: Error: in RENAME TABLE table `test`.`t1`/ or
  311. /InnoDB: Error: table `test`.`t[12]` does not exist in the InnoDB internal/ or
  312. # Test case for Bug#14233 produces the following warnings:
  313. /Stored routine 'test'.'bug14233_1': invalid value in column mysql.proc/ or
  314. /Stored routine 'test'.'bug14233_2': invalid value in column mysql.proc/ or
  315. /Stored routine 'test'.'bug14233_3': invalid value in column mysql.proc/ or
  316. # BUG#29839 - lowercase_table3.test: Cannot find table test/T1
  317. # from the internal data dictiona
  318. /Cannot find table test\/BUG29839 from the internal data dictionary/ or
  319. # BUG#32080 - Excessive warnings on Solaris: setrlimit could not
  320. # change the size of core files
  321. /setrlimit could not change the size of core files to 'infinity'/ or
  322. # rpl_extrColmaster_*.test, the slave thread produces warnings
  323. # when it get updates to a table that has more columns on the
  324. # master
  325. /Slave: Unknown column 'c7' in 't15' Error_code: 1054/ or
  326. /Slave: Can't DROP 'c7'.* 1091/ or
  327. /Slave: Key column 'c6'.* 1072/ or
  328. # Warnings generated until bug#42147 is properly resolved
  329. /Found lock of type 6 that is write and read locked/ or
  330. # rpl_idempotency.test produces warnings for the slave.
  331. ($testname eq 'rpl.rpl_idempotency' and
  332. (/Slave: Can\'t find record in \'t1\' Error_code: 1032/ or
  333. /Slave: Cannot add or update a child row: a foreign key constraint fails .* Error_code: 1452/
  334. )) or
  335. # These tests does "kill" on queries, causing sporadic errors when writing to logs
  336. (($testname eq 'rpl.rpl_skip_error' or
  337. $testname eq 'rpl.rpl_err_ignoredtable' or
  338. $testname eq 'binlog.binlog_killed_simulate' or
  339. $testname eq 'binlog.binlog_killed') and
  340. (/Failed to write to mysql\.\w+_log/
  341. )) or
  342. # rpl_bug33931 has deliberate failures
  343. ($testname eq 'rpl.rpl_bug33931' and
  344. (/Failed during slave.*thread initialization/
  345. )) or
  346. # rpl_temporary has an error on slave that can be ignored
  347. ($testname eq 'rpl.rpl_temporary' and
  348. (/Slave: Can\'t find record in \'user\' Error_code: 1032/
  349. )) or
  350. # Test case for Bug#31590 produces the following error:
  351. /Out of sort memory; increase server sort buffer size/ or
  352. # Bug#35161, test of auto repair --myisam-recover
  353. /able.*_will_crash/ or
  354. # lowercase_table3 using case sensitive option on
  355. # case insensitive filesystem (InnoDB error).
  356. /Cannot find or open table test\/BUG29839 from/ or
  357. # When trying to set lower_case_table_names = 2
  358. # on a case sensitive file system. Bug#37402.
  359. /lower_case_table_names was set to 2, even though your the file system '.*' is case sensitive. Now setting lower_case_table_names to 0 to avoid future problems./
  360. )
  361. {
  362. next; # Skip these lines
  363. }
  364. if ( /CURRENT_TEST: (.*)/ )
  365. {
  366. $testname= $1;
  367. }
  368. if ( /$pattern/ )
  369. {
  370. $found_problems= 1;
  371. print WARN basename($errlog) . ": $testname: $_";
  372. }
  373. }
  374. }
  375. }
  376. if ( $::opt_check_testcases )
  377. {
  378. # Look for warnings produced by mysqltest in testname.warnings
  379. foreach my $test_warning_file
  380. ( glob("$::glob_mysql_test_dir/r/*.warnings") )
  381. {
  382. $found_problems= 1;
  383. print WARN "Check myqltest warnings in $test_warning_file\n";
  384. }
  385. }
  386. if ( $found_problems )
  387. {
  388. mtr_warning("Got errors/warnings while running tests, please examine",
  389. "\"$warnlog\" for details.");
  390. }
  391. }
  392. }
  393. print "\n";
  394. # Print a list of testcases that failed
  395. if ( $tot_failed != 0 )
  396. {
  397. my $test_mode= join(" ", @::glob_test_mode) || "default";
  398. print "mysql-test-run in $test_mode mode: *** Failing the test(s):";
  399. foreach my $tinfo (@$tests)
  400. {
  401. if ( $tinfo->{'result'} eq 'MTR_RES_FAILED' )
  402. {
  403. print " $tinfo->{'name'}";
  404. }
  405. }
  406. print "\n";
  407. }
  408. # Print a list of check_testcases that failed(if any)
  409. if ( $::opt_check_testcases )
  410. {
  411. my @check_testcases= ();
  412. foreach my $tinfo (@$tests)
  413. {
  414. if ( defined $tinfo->{'check_testcase_failed'} )
  415. {
  416. push(@check_testcases, $tinfo->{'name'});
  417. }
  418. }
  419. if ( @check_testcases )
  420. {
  421. print "Check of testcase failed for: ";
  422. print join(" ", @check_testcases);
  423. print "\n\n";
  424. }
  425. }
  426. if ( $tot_failed != 0 || $found_problems)
  427. {
  428. mtr_error("there were failing test cases");
  429. }
  430. }
  431. ##############################################################################
  432. #
  433. # Text formatting
  434. #
  435. ##############################################################################
  436. sub mtr_print_line () {
  437. print '-' x 55, "\n";
  438. }
  439. sub mtr_print_thick_line () {
  440. print '=' x 55, "\n";
  441. }
  442. sub mtr_print_header () {
  443. print "\n";
  444. if ( $::opt_timer )
  445. {
  446. print "TEST RESULT TIME (ms)\n";
  447. }
  448. else
  449. {
  450. print "TEST RESULT\n";
  451. }
  452. mtr_print_line();
  453. print "\n";
  454. }
  455. ##############################################################################
  456. #
  457. # Log and reporting functions
  458. #
  459. ##############################################################################
  460. use IO::File;
  461. my $log_file_ref= undef;
  462. sub mtr_log_init ($) {
  463. my ($filename)= @_;
  464. mtr_error("Log is already open") if defined $log_file_ref;
  465. $log_file_ref= IO::File->new($filename, "a") or
  466. mtr_warning("Could not create logfile $filename: $!");
  467. }
  468. sub _mtr_log (@) {
  469. print $log_file_ref join(" ", @_),"\n"
  470. if defined $log_file_ref;
  471. }
  472. sub mtr_report (@) {
  473. # Print message to screen and log
  474. _mtr_log(@_);
  475. print join(" ", @_),"\n";
  476. }
  477. sub mtr_warning (@) {
  478. # Print message to screen and log
  479. _mtr_log("WARNING: ", @_);
  480. print STDERR "mysql-test-run: WARNING: ",join(" ", @_),"\n";
  481. }
  482. sub mtr_error (@) {
  483. # Print message to screen and log
  484. _mtr_log("ERROR: ", @_);
  485. print STDERR "mysql-test-run: *** ERROR: ",join(" ", @_),"\n";
  486. mtr_exit(1);
  487. }
  488. sub mtr_child_error (@) {
  489. # Print message to screen and log
  490. _mtr_log("ERROR(child): ", @_);
  491. print STDERR "mysql-test-run: *** ERROR(child): ",join(" ", @_),"\n";
  492. exit(1);
  493. }
  494. sub mtr_debug (@) {
  495. # Only print if --script-debug is used
  496. if ( $::opt_script_debug )
  497. {
  498. _mtr_log("###: ", @_);
  499. print STDERR "####: ",join(" ", @_),"\n";
  500. }
  501. }
  502. sub mtr_verbose (@) {
  503. # Always print to log, print to screen only when --verbose is used
  504. _mtr_log("> ",@_);
  505. if ( $::opt_verbose )
  506. {
  507. print STDERR "> ",join(" ", @_),"\n";
  508. }
  509. }
  510. 1;