Commit graph

22873 commits

Author SHA1 Message Date
Guilhem Bichot
ae3aaa5eb6 Fix for BUG#42012 "Maria: test maria-recovery2 fails with --embedded" and for simple failures
of Maria tests with --big (back-ports from 6.0-maria)

mysql-test/suite/maria/r/maria-big.result:
  result update
mysql-test/suite/maria/r/maria-recovery-big.result:
  result update
mysql-test/suite/maria/t/maria-big.test:
  this test didn't work anymore due to changes in 5.1 around max_allowed_packet allowed settings
  (fix back-ported from 6.0-maria)
mysql-test/suite/maria/t/maria-recovery-big-master.opt:
  this test didn't work anymore due to changes in 5.1 around max_allowed_packet allowed settings
  (fix back-ported from 6.0-maria)
mysql-test/suite/maria/t/maria-recovery-big.test:
  this test didn't work anymore due to changes in 5.1 around max_allowed_packet allowed settings
  (fix back-ported from 6.0-maria)
mysql-test/suite/maria/t/maria-recovery2-master.opt:
  Fix for BUG#42012 "Maria: test maria-recovery2 fails with --embedded": file is updated like
  maria-recovery-master.opt had already been in guilhem@mysql.com-20080701204709-pa4megwfvllq3s7g
2009-01-15 15:29:14 +01:00
Michael Widenius
7dc83c5043 Fixed bugs from my latest patch found by pushbuild:
Bug #41962 Maria: view-related test failures (insert, view, maria, trigger tests)
Added error handling for wrong update of view.
See Bug #41760 Inserting into multiple-table views is not working

mysql-test/r/delayed.result:
  Fixed test as we are now testing values before fields.
  Added new tests to test all error combinations
mysql-test/suite/maria/r/maria.result:
  Added error handling for not supported update of view.
mysql-test/suite/maria/t/maria.test:
  Added error handling for not supported update of view.
mysql-test/t/delayed.test:
  Fixed test as we are now testing values before fields.
  Added new tests to test all error combinations
sql/sql_base.cc:
  Fixed warning from valgrind
sql/sql_insert.cc:
  Don't test from which table values are in case of INSERT ... SELECT
  Run fix_fields() in values before we do it on fields.
  This is needed becasue check_view_single_update() are accessing values.
storage/maria/ma_blockrec.c:
  Don't call pagecache_delete_pages() if no pages to delete.
  This fixes a DBUG_ASSERT() error in maria_test_recovery
2009-01-09 06:11:37 +02:00
Michael Widenius
910284e6e6 Fixed bugs found by pushbuild
Added code to detect and give error when doing an insert into a view where we accessed fields in a not yet read table
Disabled test in subselect.test as the CHECK_OPTION for views doesn't work for insert.
This needs to be fixed properly later.

The problem with views are described in Bug #41760 Inserting into multiple-table views is not working

mysql-test/r/insert.result:
  Fixed wrong usage of insert into view.
mysql-test/r/subselect.result:
  Disabled wrong test (temporary)
mysql-test/suite/maria/r/maria.result:
  Added test of size of table
mysql-test/suite/maria/t/maria.test:
  Added test of size of table
mysql-test/t/insert.test:
  Fixed wrong usage of insert into view
  The bug is that during insert/update we currently don't read any of the referenced tables of the view.
  This means that we can't get a value from another table to use as part of the update.
mysql-test/t/subselect.test:
  Disabled not working test until someone has time to fix insert into view properly
  Here we where refering to last used value in t2, which is wrong.
sql/sql_insert.cc:
  Detect if we are trying to update one table in a view based on value in another, not yet read, table.
  This fixes the problem discovered in insert.test
storage/maria/ma_blockrec.c:
  Don't ignore not critical changes to the last page in the table.
  We need to write the last page as otherwise we can during aborting of a row with a duplicate key get
  state.data_file_length and the real length of file out of sync
storage/maria/ma_check.c:
  Flush the page cache even if we got an error during zerofill.
  (This fixes a call to assert() in case of a too short data file)
storage/maria/ma_pagecache.c:
  Mark page as read when we do a write of a full page.
  This fixes a bug when we got an error during read and then used direct write to page to update it
storage/maria/ma_state.c:
  Restore info->lock.type after call to maria_versioning.
  Fixed crash in maria_recover.test
storage/maria/maria_read_log.c:
  Don't write thread id in debug log. (Not needed as maria_read_log is a single treaded program)
2008-12-27 04:05:16 +02:00
Michael Widenius
3ef5b1fd58 Automatic merge with MySQL-5.1-Maria tree 2008-12-22 02:22:13 +02:00
Michael Widenius
3ecbee7c47 Adde new tests for maria and partitioning 2008-12-22 02:19:43 +02:00
Michael Widenius
86fcfb1508 Fix for Bug#40311 Assert in MARIA_RECORD_POS during pushbuild 2 test:
Fixed bug when removing a newly inserted record (in case of duplicate key).
The bug caused a crash for rows with several blobs and the first blob was small enough to fit into the head page.
Don't change state_history if nothing changed (speed optimization that also simplifies logic).
Reset state_history if we added/deleted or updated rows without versioning.
Fixed wrong test in trnman_exists_active_transactions() if state is visible or not.

Other bugs fixed:
Fixed wrong argument to (lock->get_status) when we had to wait for TL_WRITE_CONCURRENT_INSERT.
Item_equal::update_used_tables() didn't calculate const_item_cache properly.
Added assert's to detect if join_read_const_table() was called under wrong assumptions..
Fixed that _ma_setup_live_state() is called from thr_lock() instead of handler::external_lock().
This was needed to get versioning information to be setup correctly.
Fixed error in debug binaries during a call to _ma_check_table_is_closed() when another thread was opening/closing a table.
Fixed wrong test when finding right history_state to use.

mysql-test/suite/maria/r/maria.result:
  Added test for Bug#40311 Assert in MARIA_RECORD_POS during pushbuild 2 test
mysql-test/suite/maria/t/maria.test:
  Added test for Bug#40311 Assert in MARIA_RECORD_POS during pushbuild 2 test
mysys/thr_lock.c:
  Fixed wrong argument to (lock->get_status) when we had to wait for TL_WRITE_CONCURRENT_INSERT
sql/item_cmpfunc.cc:
  Item_equal::update_used_tables() didn't calculate const_item_cache properly, which later caused a wrong result for item->const_item()
sql/sql_base.cc:
  In debug mode, Initilize record buffer with unexpected data to catch usage of uninitialized memory
sql/sql_select.cc:
  Fixed indentation
  Added assert's to detect if join_read_const_table() was called under wrong assumptions.
  One assert() is disabled for now as Item_equal() doesn't behave as expected.
storage/maria/ha_maria.cc:
  Move calling to _ma_setup_live_state() to ma_state.c::_ma_block_get_status()
  This was needed as _ma_setup_live_state() needed to know if the table will be used concurrently or not
storage/maria/ma_blockrec.c:
  Fixed bug when removing a newly inserted record (in case of duplicate key).
  The bug caused a crash for rows with several blobs and the first blob was small enough to fit into the head page.
storage/maria/ma_dbug.c:
  Added mutex to protect the open table list during _ma_check_table_is_closed().
  Without the protection we could get a error in debug binaries during a call to _ma_check_table_is_closed()
storage/maria/ma_delete_table.c:
  Removed not used code
storage/maria/ma_rename.c:
  Removed not used code
storage/maria/ma_state.c:
  Fixed wrong test when finding right history_state to use
  Mark in tables->state_current.no_transid if we are using transid's or not.
  Don't change state_history if nothing changed (speed optimization that also simplifies logic)
  Reset state_history if we added/deleted or updated rows without versioning.
  More DBUG_ASSERT's and more DBUG
  Updated maria_versioning() to initialize environment before calling _ma_blok_get_status(). This was needed because of the new logic in _ma_block_get_status()
storage/maria/ma_state.h:
  Added flags to detect if table changed and/or if we changed table without versioning
storage/maria/ma_write.c:
  Simple cleanups (No logic changes)
storage/maria/trnman.c:
  Fixed wrong test in trnman_exists_active_transactions() if state is visible or not.
2008-12-22 02:17:37 +02:00
Christoffer Hall
3a056ae502 Make sure Maria can be run with different page sizes in test system. 2008-12-15 13:34:57 +01:00
Michael Widenius
2b73d21530 Merge with main Maria tree 2008-12-10 23:42:57 +02:00
Michael Widenius
dc4c35fd3d Added missing prefix to options that caused --embedded to fail 2008-12-10 18:31:50 +02:00
Guilhem Bichot
926aaf4635 Merge of 5.1-main into 5.1-maria. There were no changes to storage/myisam, mysys/mf_keycache.c, mysql-test/t/*myisam*
since previous merge. MARIA_PAGECACHE_READS in maria-preload.test are down a little bit (5%), which must be a good
side-effect of some sql/ change.
2008-12-10 10:02:25 +01:00
Michael Widenius
9948682b43 Merge with base Maria tree
Remove warnings from test logs about depricated options

mysql-test/t/events_logs_tests-master.opt:
  Remove warnings from test logs about depricated options
mysql-test/t/log_tables-big-master.opt:
  Remove warnings from test logs about depricated options
mysql-test/t/log_tables-master.opt:
  Remove warnings from test logs about depricated options
mysql-test/t/multi_statement-master.opt:
  Remove warnings from test logs about depricated options
mysql-test/t/ps-master.opt:
  Remove warnings from test logs about depricated options
mysql-test/t/show_check-master.opt:
  Remove warnings from test logs about depricated options
mysql-test/t/slow_query_log_file_basic-master.opt:
  Remove warnings from test logs about depricated options
mysql-test/t/slow_query_log_file_func-master.opt:
  Remove warnings from test logs about depricated options
mysql-test/t/union-master.opt:
  Remove warnings from test logs about depricated options
sql/mysqld.cc:
  Don't give warnings for empty log file names
2008-12-09 12:29:33 +02:00
Michael Widenius
d0fb8270df Fixed problem with crash in Maria _ma_setup_live_state() where history link didn't include needed state
mysql-test/mysql-test-run.pl:
  Remove warnings in log about depricated mysqld options
storage/maria/ma_state.c:
  More DBUG_PRINT
storage/maria/trnman.c:
  Fixed wrong test if commit_trid is visible
2008-12-08 20:31:16 +02:00
Guilhem Bichot
ccfb9c32f8 merge with latest 5.1-maria 2008-12-05 22:25:38 +01:00
Guilhem Bichot
91bc9cc9e6 Fix for BUG#41037 "Maria: recovery failure (pushbuild2)" (checkpoint bug).
mysql-test/suite/maria/r/maria-recovery3.result:
  result.
mysql-test/suite/maria/t/maria-recovery3-master.opt:
  usual recovery test options
mysql-test/suite/maria/t/maria-recovery3.test:
  Test for BUG#41037. Without the bugfix, the test would hang because Recovery would fail with "undo_key_insert got error 126": Recovery would believe INSERT of 2 is uncommitted, try to execute its UNDO_KEY_INSERT, fail to find the key to delete because DELETE deleted it. That failure of _ma_ck_real_delete() would mark table as corrupted (see
  in d_search()) which is error 126 (HA_ERR_CRASHED).
storage/maria/ma_blockrec.c:
  set trn->rec_lsn to LSN of commit record, when writing it.
storage/maria/ma_blockrec.h:
  new function
storage/maria/ma_commit.c:
  when committing or rolling back, rec_lsn should be LSN_IMPOSSIBLE: assertion is moved here
  from trnman_end_trn(), because now ma_commit() can set rec_lsn and so when we reach trnman_end_trn()
  it's not LSN_IMPOSSIBLE anymore.
  Adding debug possibility to pause between COMMIT record write and trnman_commit_trn(), to be
  able to fire checkpoint in between.
storage/maria/ma_loghandler.c:
  in-write hook for COMMIT records
storage/maria/ma_recovery.c:
  More debugging info in maria_recovery.trace, to see how the starting point of REDO phase is determined
storage/maria/trnman.c:
  assertion cannot be here anymore see ma_commit.c
2008-12-05 22:11:46 +01:00
Guilhem Bichot
44d3917f7a Fix for BUG#41102 "Maria: maria-no-logging.test fails randomly on Win64"
mysql-test/include/maria_empty_logs.inc:
  move mysqladmin call to include file for reusal (so that others don't have to hit the same bug in their tests);
  this include file additionally waits for disconnection. Reasons for BUG#41102:
  - in maria-no-logging.test, we shut down mysqld in maria_empty_logs.inc, remove logs, tell mtr that it can
  restart mysqld, then wait for being connected (wait_until_connected_again.inc), then send commands to new mysqld.
  - but under Windows "mysqladmin shutdown" does not wait for mysqld to be down, so we accidentally removed logs
  while it was shutting down, wait_until_connected_again found that we were connected (because it was shutting
  down slowly, connections were not yet broken), sent new commands, and one of them failed because mysqld finally
  closed connections.
  - the fix is to just wait for disconnection after shutdown.
  - in a sense, the catch is the "again" in wait_until_connected_again.inc...
mysql-test/include/mysqladmin_shutdown.inc:
  shutdown with mysqladmin AND waiting for shutdown to complete (needed on Windows)
mysql-test/include/wait_until_connected_again.inc:
  comment
mysql-test/include/wait_until_disconnected.inc:
  script which waits until connection is lost
2008-12-05 15:08:09 +01:00
Sergei Golubchik
d00d63dda2 merged 2008-12-05 14:42:14 +01:00
Georgi Kodinov
1bb6a0ba9f Disable wait_timeout_func and report bug #41255. 2008-12-05 13:24:19 +02:00
Guilhem Bichot
45521d9710 Fix for pushbuild failure (test which can't run in embedded mode) and compiler warning
mysql-test/suite/maria/t/maria_showlog_error.test:
  test which can't run in embedded mode
storage/innobase/handler/ha_innodb.cc:
  compiler warning
2008-12-05 10:15:23 +01:00
Sergei Golubchik
7881dc1f9f dbug fix: only do safemalloc checks if a function is selected
mysqlslap: fix a crash when mysql_store_result() fails

client/mysqlslap.c:
  fix a crash
dbug/dbug.c:
  only do safemalloc checks if a function is selected
mysql-test/mysql-test-run.pl:
  it's easier to add new gdb parameters this way
storage/maria/ma_open.c:
  typo in a comment
2008-12-02 16:29:59 +01:00
Georgi Kodinov
47cff6998a merged addendum to bug 39920 to 5.1-bugteam 2008-12-01 17:43:51 +02:00
Georgi Kodinov
7f9e0b9bfb addendum to the fix for bug #39920 : post-merge test suite fixes 2008-12-01 17:41:06 +02:00
Georgi Kodinov
6afd8123a3 merged bug 39920 and 5.1-main to 5.1-bugteam 2008-12-01 17:22:16 +02:00
Georgi Kodinov
7114fde7c0 merged bug 39920 to 5.0-bugteam 2008-12-01 16:41:22 +02:00
Georgi Kodinov
f56e43ce52 Bug #39920: MySQL cannot deal with Leap Second expression in string literal.
Updated MySQL time handling code to react correctly on UTC leap second additions.
MySQL functions that return the OS current time, like e.g. CURDATE(), NOW() etc
will return :59:59 instead of :59:60 or 59:61.
As a result the reader will receive :59:59 for 2 or 3 consecutive seconds 
during the leap second.
This fix will not affect the values returned by UNIX_TIMESTAMP() for leap seconds.
But note that when converting the value returned by UNIX_TIMESTAMP() to broken 
down time the correction of leap seconds will still be applied.
Note that this fix will make a difference *only* if the OS is specially configured
to return leap seconds from the OS time calls or when using a MySQL time zone 
defintion that has leap seconds.
Even after this change date/time literals (or other broken down time 
representations) with leap seconds (ending on :59:60 or 59:61) will still be 
considered illegal and discarded by the server with an error or 
a warning depending on the sql mode.
Added a test case to demonstrate the effect of the fix.

mysql-test/r/timezone3.result:
  Bug #39920: test case
mysql-test/std_data/Moscow_leap:
  Bug #39920: updated the Moscow time zone to Dr. Olson's tzdata 2008i 
  to accomodate for the 2008 leap second
mysql-test/t/timezone3.test:
  Bug #39920: test case
sql/tztime.cc:
  Bug #39920: adjust leap seconds (:60 or :61) to :59
sql/tztime.h:
  Bug #39920: adjust leap seconds (:60 or :61) to :59
2008-12-01 16:18:35 +02:00
unknown
2b51150231 Do not use MY_WME in the stat call which errors we process on high level.
(BUG#41127: Maria: assertion when SHOW ENGINE MARIA LOGS and missing logs)

mysql-test/suite/maria/r/maria_showlog_error.result:
  test suite for the BUG#41127
mysql-test/suite/maria/t/maria_showlog_error.test:
  test suite for the BUG#41127
storage/maria/ha_maria.cc:
  Do not use MY_WME in the stat call which errors we process on high level.
2008-12-01 15:21:37 +02:00
Georgi Kodinov
5f109f4882 merge of the addenum for bug 37339 to 5.1-bugteam 2008-12-01 15:15:33 +02:00
Georgi Kodinov
a1e9b6ba1e Addendum to bug #37339 : make the test case portable to windows
by using and taking out a full path.

mysql-test/r/ctype_filesystem.result:
  Bug #37399: use MYSQL_TEST_DIR rooted test
mysql-test/t/ctype_filesystem-master.opt:
  Bug #37399: use MYSQL_TEST_DIR rooted test
mysql-test/t/ctype_filesystem.test:
  Bug #37399: use MYSQL_TEST_DIR rooted test
2008-12-01 13:34:53 +02:00
Sergei Golubchik
f1906c62d5 Bug#34374: mysql generates incorrect warning
an item was evaluated unnecessary, fix that by checking preconditions before evaluating the item

sql/sql_select.cc:
  an item was evaluated unnecessary, fix that by checking preconditions before evaluating the item
2008-11-29 00:27:13 +01:00
Ingo Struewing
622db26040 auto-merge 2008-11-28 21:55:52 +01:00
Matthias Leich
58288b6939 Merge of last pushes into GCA tree, no conflicts
Diff to actual 5.0-bugteam is revno: 2725 only
2008-11-28 19:47:08 +01:00
Gleb Shchepa
86a20bd3dc manual merge 5.0-bugteam --> 5.1-bugteam (bug 33461) 2008-11-28 21:35:48 +04:00
Gleb Shchepa
d15cbc1a1a Bug #40745: Error during WHERE clause calculation in UPDATE
leads to an assertion failure

Any run-time error in stored function (like recursive function
call or update of table that is already updating by statement
which invoked this stored function etc.) that was used in some
expression of the single-table UPDATE statement caused an
assertion failure.
Multiple-table UPDATE (as well as INSERT and both single- and
multiple-table DELETE) are not affected.


mysql-test/r/update.result:
  Added test case for bug #40745.
mysql-test/t/update.test:
  Added test case for bug #40745.
sql/sql_update.cc:
  Bug #40745: Error during WHERE clause calculation in UPDATE
              leads to an assertion failure
  
  The mysql_update function has been updated to take into account
  the status of invoked stored functions before setting the status
  of whole UPDATE query to OK.
2008-11-28 20:36:07 +04:00
Gleb Shchepa
41ccbefcc4 Bug #33461: SELECT ... FROM <view> USE INDEX (...) throws
an error

Even after the fix for bug 28701 visible behaviors of
SELECT FROM a view and SELECT FROM a regular table are
little bit different:

1. "SELECT FROM regular table USE/FORCE/IGNORE(non
   existent index)" fails with a "ERROR 1176 (HY000):
   Key '...' doesn't exist in table '...'"

2. "SELECT FROM view USING/FORCE/IGNORE(any index)" fails
   with a "ERROR 1221 (HY000): Incorrect usage of
   USE/IGNORE INDEX and VIEW".  OTOH "SHOW INDEX FROM
   view" always returns empty result set, so from the point
   of same behaviour view we trying to use/ignore non
   existent index.

To harmonize the behaviour of USE/FORCE/IGNORE(index)
clauses in SELECT from a view and from a regular table the
"ERROR 1221 (HY000): Incorrect usage of USE/IGNORE INDEX
and VIEW" message has been replaced with the "ERROR 1176
(HY000): Key '...' doesn't exist in table '...'" message
like for tables and non existent keys.


mysql-test/r/view.result:
  Added test case for bug #33461.
  Updated test case for bug 28701.
mysql-test/t/view.test:
  Added test case for bug #33461.
  Updated test case for bug 28701.
sql/sql_view.cc:
  Bug #33461: SELECT ... FROM <view> USE INDEX (...) throws
              an error
  
  To harmonize the behaviour of USE/FORCE/IGNORE(index)
  clauses in SELECT from a view and from a regular table the
  "ERROR 1221 (HY000): Incorrect usage of USE/IGNORE INDEX
  and VIEW" message has been replaced with the "ERROR 1176
  (HY000): Key '...' doesn't exist in table '...'" message
  like for tables and non existent keys.
2008-11-28 20:13:12 +04:00
Georgi Kodinov
552a1bd352 merged bug 37339 to 5.1-bugteam 2008-11-28 17:27:12 +02:00
Georgi Kodinov
f1a9d567c1 merged bug 37339 to 5.0-bugteam 2008-11-28 16:32:04 +02:00
Georgi Kodinov
8e688a7a02 Bug #37339: SHOW VARIABLES not working properly with multi-byte datadir
The SHOW VARIABLES LIKE .../SELECT @@/SELECT ... FROM INFORMATION_SCHEMA.VARIABLES
were assuming that all the system variables are in system charset (UTF-8).
However the variables that are settable through command line will have a different
character set (character_set_filesystem).
Fixed the server to remember the correct character set of basedir, datadir, tmpdir,
ssl, plugin_dir, slave_load_tmpdir, innodb variables; init_connect and init_slave 
variables and use it when processing data.

mysql-test/r/ctype_filesystem.result:
  Bug #37339: test case (should be in utf-8)
mysql-test/t/ctype_filesystem-master.opt:
  Bug #37339: test case (should be in ISO-8859-1)
mysql-test/t/ctype_filesystem.test:
  Bug #37339: test case
sql/mysqld.cc:
  Bug #37339: remember the correct character set for init_slave and init_connect
sql/set_var.cc:
  Bug #37339: 
    - remember the character set of the relevant variables
    - implement storing and using the correct 
      character set
sql/set_var.h:
  Bug #37339: implement storing and using the correct 
  character set
sql/sql_show.cc:
  Bug #37339: implement storing and using the correct 
  character set
2008-11-28 16:25:16 +02:00
Ingo Struewing
f525d35b51 merge
.bzrignore:
  Added autom4te.cache and language directories in sql/share to ignorefile.
2008-11-28 15:01:09 +01:00
Sergey Glukhov
be1e992812 automerge 2008-11-28 17:15:29 +04:00
Sergey Glukhov
fef07511e3 error code is changed to satisfy Win NT 2008-11-28 17:12:43 +04:00
Ingo Struewing
8e9e95f2d7 merge 2008-11-28 12:38:49 +01:00
Sergey Glukhov
710b7125da 5.0-bugteam->5.1-bugteam merge
sql/slave.cc:
  compiler warning fix
2008-11-28 15:04:09 +04:00
Sergey Glukhov
78119b2d04 pushbuild failure fixes
mysql-test/r/perror-win.result:
  pushbuild failure fix
mysql-test/t/perror-win.test:
  pushbuild failure fix
sql/item_func.cc:
  pushbuild failure fix
2008-11-28 14:50:13 +04:00
Ingo Struewing
a4abe291dc merge 2008-11-27 20:39:54 +01:00
Ingo Struewing
ccb1990531 2008-11-27 18:39:43 +01:00
Tatiana A. Nurnberg
8c0c30aa90 auto-merge 2008-11-27 17:32:34 +01:00
Tatiana A. Nurnberg
50cfde5328 auto-merge 2008-11-27 17:17:16 +01:00
Horst Hunger
5f678447cc due to merge. 2008-11-27 16:48:00 +01:00
Ingo Struewing
7bfc13296f merge 2008-11-27 16:28:50 +01:00
Guilhem Bichot
255f8feb4c Fix for BUG#40661 "Maria: crash in embedded server (when detecting deadlock?)"
bug is actually a weirdness in test system, so moving test portion into maria_notembedded.test

mysql-test/suite/maria/r/maria.result:
  result update
mysql-test/suite/maria/r/maria_notembedded.result:
  result update
mysql-test/suite/maria/t/maria.test:
      Removing test portion into maria_notembedded.test. Explanation below.
      Running maria.test with --mem --embedded --valgrind I got:
      ==378== Invalid read of size 4
      ==378==    at 0x857C755: _lf_pinbox_real_free (lf_alloc-pin.c:342)
      ==378==    by 0x857C640: _lf_pinbox_free (lf_alloc-pin.c:267)
      ==378==    by 0x857D50C: ldelete (lf_hash.c:226)
      ==378==    by 0x857DBC1: lf_hash_delete (lf_hash.c:429)
      ==378==    by 0x8243D82: unlock_lock_and_free_resource
      (waiting_threads.c:676)
      ==378==    by 0x8244A79: wt_thd_release (waiting_threads.c:948)
      ==378==    by 0x83F301D: wt_thd_release_self (trnman.c:98)
      ==378==    by 0x83F3D49: trnman_end_trn (trnman.c:431)
      ==378==    by 0x837C437: ma_commit (ma_commit.c:60)
      ==378==    by 0x835F082: ha_maria::external_lock(THD*, int)
      (ha_maria.cc:2387)
      ==378==    by 0x84D1011: handler::ha_external_lock(THD*, int)
      (handler.cc:4433)
      ==378==    by 0x856DA92: unlock_external(THD*, st_table**, unsigned)
      (lock.cc:786)
      ==378==    by 0x856DD6F: mysql_unlock_tables(THD*, st_mysql_lock*)
      (lock.cc:389)
      ==378==    by 0x8274A57: close_thread_tables(THD*) (sql_base.cc:1307)
      ==378==    by 0x82ABEC3: unlock_locked_tables(THD*) (sql_parse.cc:99)
      ==378==    by 0x82B0BB3: mysql_execute_command(THD*)
      (sql_parse.cc:3372)
      ==378==  Address 0x5894a0c is 164 bytes inside a block of size 184
      free'd
      ==378==    at 0x40233FC: free (vg_replace_malloc.c:323)
      ==378==    by 0x823CF92: my_thread_end (my_thr_init.c:348)
      ==378==    by 0x8200FEE: mysql_thread_end (libmysql.c:250)
      ==378==    by 0x81A9487: send_one_query (mysqltest.c:535)
      ==378==    by 0x4050111: start_thread (in /lib/libpthread-2.5.so)
      ==378==    by 0x41A52ED: clone (in /lib/libc-2.5.so)
      
      (among other errors). The line where the invalid read happens is:
        if (available_stack_size(&pinbox, *pins->stack_ends_here) >
      alloca_size)
      and stack_ends_here was previously set here:
        el->stack_ends_here= & my_thread_var->stack_ends_here;
      The mysqltest "send" command, in embedded mode, is implemented this way
      (mysqltest.c:do_send_query()): a *new OS thread* is created in
      mysqltest, and does this:
      
        mysql_thread_init();
        VOID(mysql_send_query(&cn->mysql, cn->cur_query,
      cn->cur_query_len));
        mysql_thread_end();
      
      So, con_d "send insert t1 values (2)" creates a new OS thread, which
      gets a thread-specific data (mysql_thread_init()), then sends the
      query; in particular, this sets el->stack_ends_here to a pointer inside
      the thread-specific data (see my_thread_var above), that is, thd->pins
      depends on the thread-specific data.
      This sent "insert" blocks as expected, thread-specific data is free()d
      (my_thread_end() above), OS thread terminates.
      Then "default" connection runs "insert t1 values (3)"
      which blocks on the 3 already inserted by the con_d.
      This blocking (see waiting_threads.c) creates a WT_RESOURCE, which has,
      as owner, con_d's WT_THD.
      When con_d calls "unlock tables" (see stack trace), it wants to release
      this resource, which involves con_d's thd->pins, so it ends up reading
      stack_ends_here which points inside the freed thread-specific data =>
      Valgrind error, crashes...
      So this is an effect of having one single connection (con_d) for which
      two queries:
      send insert t1 values (2)
      unlock tables
      are done by different OS threads. That is indeed weird design of
      mysqltest, and it breaks on the dependency of lf_alloc-pin.c on
      thread-specific data. It is maybe already explained in those comments
      in lf_alloc-pin.c:
      "  It is assumed that pins belong to a THD and are not transferable
        between THD's (LF_PINS::stack_ends_here being a primary reason
        for this limitation)."
      "    It is assumed that pins belong to a thread and are not
      transferable
          between threads."
      
      In correct usage of libmysqld (no two queries sent for one connection
      by two threads), this problem would not happen, so I call it a
      deficiency of the test system.
mysql-test/suite/maria/t/maria_notembedded.test:
  moving test portion into maria_notembedded.test
2008-11-27 16:13:02 +01:00
Sergey Glukhov
0385618e05 5.0-bugteam->5.1-bugteam merge 2008-11-27 19:03:13 +04:00