Commit graph

1473 commits

Author SHA1 Message Date
lars/lthalmann@mysql.com/dl145j.mysql.com
9c6dc8c853 Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge
2007-03-31 00:15:20 +02:00
lars/lthalmann@mysql.com/dl145h.mysql.com
75668471d1 Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge
2007-03-29 12:25:28 +02:00
serg@sergbook.mysql.com
1af6b027d6 Merge sergbook.mysql.com:/usr/home/serg/Abk/mysql-4.1
into  sergbook.mysql.com:/usr/home/serg/Abk/mysql-5.0-build
2007-03-24 14:05:27 +02:00
serg@sergbook.mysql.com
18a01e7261 nptl: typo fixed. sigaddset restored 2007-03-24 14:03:27 +02:00
serg@sergbook.mysql.com
e4164cda68 Merge sergbook.mysql.com:/usr/home/serg/Abk/mysql-4.1
into  sergbook.mysql.com:/usr/home/serg/Abk/mysql-5.0-build
2007-03-23 20:39:34 +02:00
serg@sergbook.mysql.com
d2d72bfc58 reverted linuxthreads thr_client_alarm fix (not future-proof)
fixed differently: wake up select_thread with THR_SERVER_ALARM instead
2007-03-23 20:37:20 +02:00
serg@sergbook.mysql.com
3e9d98b039 Merge sergbook.mysql.com:/usr/home/serg/Abk/mysql-4.1
into  sergbook.mysql.com:/usr/home/serg/Abk/mysql-5.0-build
2007-03-23 16:37:19 +02:00
serg@sergbook.mysql.com
b37c197512 Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into  sergbook.mysql.com:/usr/home/serg/Abk/mysql-4.1
2007-03-23 14:57:55 +02:00
serg@sergbook.mysql.com
2220fe2774 move thr_client_alarm initialization to mysqld.cc
(in thr_alarm.cc it happened too late).
2007-03-23 13:38:42 +02:00
guilhem@gbichot3.local
f0a95a4e20 - renaming TMP_TABLE to NON_TRANSACTIONAL_TMP_TABLE because this is
what it actually means (Monty approved the renaming)
- correcting description of transaction_alloc command-line options
(our manual is correct)
- fix for a failure of rpl_trigger.
2007-03-22 15:07:32 +01:00
dlenev@mockturtle.local
01bd08b5d7 Fix for bug #25966 "2MB per second endless memory consumption after LOCK
TABLE ... WRITE".

Memory and CPU hogging occured when connection which had to wait for table
lock was serviced by thread which previously serviced connection that was
killed (note that connections can reuse threads if thread cache is enabled).
One possible scenario which exposed this problem was when thread which
provided binlog dump to replication slave was implicitly/automatically
killed when the same slave reconnected and started pulling data through
different thread/connection.
The problem also occured when one killed particular query in connection
(using KILL QUERY) and later this connection had to wait for some table
lock.

This problem was caused by the fact that thread-specific mysys_var::abort
variable, which indicates that waiting operations on mysys layer should
be aborted (this includes waiting for table locks), was set by kill
operation but was never reset back. So this value was "inherited" by the
following statements or even other connections (which reused the same
physical thread). Such discrepancy between this variable and THD::killed
flag broke logic on SQL-layer and caused CPU and memory hogging.

This patch tries to fix this problem by properly resetting this member.

There is no test-case associated with this patch since it is hard to test
for memory/CPU hogging conditions in our test-suite.
2007-03-15 11:51:35 +03:00
dlenev@mockturtle.local
f2cb664174 Fix for bug #25966 "2MB per second endless memory consumption after LOCK
TABLE ... WRITE".

CPU hogging occured when connection which had to wait for table lock was
serviced by thread which previously serviced connection that was killed
(note that connections can reuse threads if thread cache is enabled).
One possible scenario which exposed this problem was when thread which
provided binlog dump to replication slave was implicitly/automatically
killed when the same slave reconnected and started pulling data through
different thread/connection.
In 5.* versions memory hogging was added to CPU hogging. Moreover in
those versions the problem also occured when one killed particular query
in connection (using KILL QUERY) and later this connection had to wait for
some table lock.

This problem was caused by the fact that thread-specific mysys_var::abort
variable, which indicates that waiting operations on mysys layer should
be aborted (this includes waiting for table locks), was set by kill
operation but was never reset back. So this value was "inherited" by the
following statements or even other connections (which reused the same
physical thread). Such discrepancy between this variable and THD::killed
flag broke logic on SQL-layer and caused CPU and memory hogging.

This patch tries to fix this problem by properly resetting this member.

There is no test-case associated with this patch since it is hard to test
for memory/CPU hogging conditions in our test-suite.
2007-03-15 11:30:17 +03:00
msvensson@pilot.blaudden
49d862230e Merge bk-internal:/home/bk/mysql-5.0-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-03-08 13:30:04 +01:00
tsmith@quadxeon.mysql.com
c06499b210 Merge quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/50
into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/mrg0306/50
2007-03-07 23:55:25 +01:00
kostja@bodhi.local
c2e0e5af09 Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  bodhi.local:/opt/local/work/mysql-5.0-26750
2007-03-07 12:28:16 +03:00
kostja@bodhi.local
86f02cd378 A fix for Bug#26750 "valgrind leak in sp_head" (and post-review
fixes).

The legend: on a replication slave, in case a trigger creation
was filtered out because of application of replicate-do-table/
replicate-ignore-table rule, the parsed definition of a trigger was not 
cleaned up properly. LEX::sphead member was left around and leaked 
memory. Until the actual implementation of support of 
replicate-ignore-table rules for triggers by the patch for Bug 24478 it 
was never the case that "case SQLCOM_CREATE_TRIGGER"
was not executed once a trigger was parsed,
so the deletion of lex->sphead there worked and the memory did not leak.

The fix: 

The real cause of the bug is that there is no 1 or 2 places where
we can clean up the main LEX after parse. And the reason we 
can not have just one or two places where we clean up the LEX is
asymmetric behaviour of MYSQLparse in case of success or error. 

One of the root causes of this behaviour is the code in Item::Item()
constructor. There, a newly created item adds itself to THD::free_list
- a single-linked list of Items used in a statement. Yuck. This code
is unaware that we may have more than one statement active at a time,
and always assumes that the free_list of the current statement is
located in THD::free_list. One day we need to be able to explicitly
allocate an item in a given Query_arena.
Thus, when parsing a definition of a stored procedure, like
CREATE PROCEDURE p1() BEGIN SELECT a FROM t1; SELECT b FROM t1; END;
we actually need to reset THD::mem_root, THD::free_list and THD::lex
to parse the nested procedure statement (SELECT *).
The actual reset and restore is implemented in semantic actions
attached to sp_proc_stmt grammar rule.
The problem is that in case of a parsing error inside a nested statement
Bison generated parser would abort immediately, without executing the
restore part of the semantic action. This would leave THD in an 
in-the-middle-of-parsing state.
This is why we couldn't have had a single place where we clean up the LEX
after MYSQLparse - in case of an error we needed to do a clean up
immediately, in case of success a clean up could have been delayed.
This left the door open for a memory leak.

One of the following possibilities were considered when working on a fix:
- patch the replication logic to do the clean up. Rejected
as breaks module borders, replication code should not need to know the
gory details of clean up procedure after CREATE TRIGGER.
- wrap MYSQLparse with a function that would do a clean up.
Rejected as ideally we should fix the problem when it happens, not
adjust for it outside of the problematic code.
- make sure MYSQLparse cleans up after itself by invoking the clean up
functionality in the appropriate places before return. Implemented in 
this patch.
- use %destructor rule for sp_proc_stmt to restore THD - cleaner
than the prevoius approach, but rejected
because needs a careful analysis of the side effects, and this patch is 
for 5.0, and long term we need to use the next alternative anyway
- make sure that sp_proc_stmt doesn't juggle with THD - this is a 
large work that will affect many modules.

Cleanup: move main_lex and main_mem_root from Statement to its
only two descendants Prepared_statement and THD. This ensures that
when a Statement instance was created for purposes of statement backup,
we do not involve LEX constructor/destructor, which is fairly expensive.
In order to track that the transformation produces equivalent 
functionality please check the respective constructors and destructors
of Statement, Prepared_statement and THD - these members were
used only there.
This cleanup is unrelated to the patch.
2007-03-07 12:24:46 +03:00
tsmith@quadxeon.mysql.com
a15fe85de2 Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/mrg0306/50
2007-03-07 06:54:35 +01:00
malff/marcsql@weblab.(none)
9f0b0df961 Merge malff@bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into  weblab.(none):/home/marcsql/TREE/mysql-5.0-8407_b
2007-03-06 11:30:08 -07:00
malff/marcsql@weblab.(none)
b216d959bb Bug#8407 (Stored functions/triggers ignore exception handler)
Bug 18914 (Calling certain SPs from triggers fail)
Bug 20713 (Functions will not not continue for SQLSTATE VALUE '42S02')
Bug 21825 (Incorrect message error deleting records in a table with a
  trigger for inserting)
Bug 22580 (DROP TABLE in nested stored procedure causes strange dependency
  error)
Bug 25345 (Cursors from Functions)


This fix resolves a long standing issue originally reported with bug 8407,
which affect the behavior of Stored Procedures, Stored Functions and Trigger
in many different ways, causing symptoms reported by all the bugs listed.
In all cases, the root cause of the problem traces back to 8407 and how the
server locks tables involved with sub statements.

Prior to this fix, the implementation of stored routines would:
- compute the transitive closure of all the tables referenced by a top level
statement
- open and lock all the tables involved
- execute the top level statement
"transitive closure of tables" means collecting:
- all the tables,
- all the stored functions,
- all the views,
- all the table triggers
- all the stored procedures
involved, and recursively inspect these objects definition to find more
references to more objects, until the list of every object referenced does
not grow any more.
This mechanism is known as "pre-locking" tables before execution.
The motivation for locking all the tables (possibly) used at once is to
prevent dead locks.

One problem with this approach is that, if the execution path the code
really takes during runtime does not use a given table, and if the table is
missing, the server would not execute the statement.
This in particular has a major impact on triggers, since a missing table
referenced by an update/delete trigger would prevent an insert trigger to run.

Another problem is that stored routines might define SQL exception handlers
to deal with missing tables, but the server implementation would never give
user code a chance to execute this logic, since the routine is never
executed when a missing table cause the pre-locking code to fail.

With this fix, the internal implementation of the pre-locking code has been
relaxed of some constraints, so that failure to open a table does not
necessarily prevent execution of a stored routine.

In particular, the pre-locking mechanism is now behaving as follows:

1) the first step, to compute the transitive closure of all the tables
possibly referenced by a statement, is unchanged.

2) the next step, which is to open all the tables involved, only attempts
to open the tables added by the pre-locking code, but silently fails without
reporting any error or invoking any exception handler is the table is not
present. This is achieved by trapping internal errors with
Prelock_error_handler

3) the locking step only locks tables that were successfully opened.

4) when executing sub statements, the list of tables used by each statements
is evaluated as before. The tables needed by the sub statement are expected
to be already opened and locked. Statement referencing tables that were not
opened in step 2) will fail to find the table in the open list, and only at
this point will execution of the user code fail.

5) when a runtime exception is raised at 4), the instruction continuation
destination (the next instruction to execute in case of SQL continue
handlers) is evaluated.
This is achieved with sp_instr::exec_open_and_lock_tables()

6) if a user exception handler is present in the stored routine, that
handler is invoked as usual, so that ER_NO_SUCH_TABLE exceptions can be
trapped by stored routines. If no handler exists, then the runtime execution
will fail as expected.

With all these changes, a side effect is that view security is impacted, in
two different ways.

First, a view defined as "select stored_function()", where the stored
function references a table that may not exist, is considered valid.
The rationale is that, because the stored function might trap exceptions
during execution and still return a valid result, there is no way to decide
when the view is created if a missing table really cause the view to be invalid.

Secondly, testing for existence of tables is now done later during
execution. View security, which consist of trapping errors and return a
generic ER_VIEW_INVALID (to prevent disclosing information) was only
implemented at very specific phases covering *opening* tables, but not
covering the runtime execution. Because of this existing limitation,
errors that were previously trapped and converted into ER_VIEW_INVALID are
not trapped, causing table names to be reported to the user.
This change is exposing an existing problem, which is independent and will
be resolved separately.
2007-03-05 19:42:07 -07:00
msvensson@pilot.blaudden
a30867bc65 Merge pilot.blaudden:/home/msvensson/mysql/bug21781/my50-bug21781
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-03-05 11:50:59 +01:00
msvensson@pilot.blaudden
9a2eea4019 Add "have_ssl" as synonym for "have_openssl" 2007-03-05 10:03:42 +01:00
msvensson@pilot.blaudden
f5778fc73e Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-03-01 18:12:56 +01:00
rafal@quant.(none)
8aee1f6e89 Fixes of compilation warnings and errors. 2007-03-01 08:41:13 +01:00
msvensson@pilot.blaudden
6fac51be9f Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint-bug20166
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-02-28 16:40:03 +01:00
msvensson@pilot.blaudden
b0ab925389 Merge pilot.blaudden:/home/msvensson/mysql/mysql-4.1-maint
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-02-28 16:39:26 +01:00
msvensson@pilot.blaudden
6ca22c6672 Bug#24878 mysql server doesn't log incident time in "mysqld got signal 11" error messages
- Add printout of current time when mysqld is killed by an
   unhandled signal
2007-02-28 16:37:50 +01:00
msvensson@pilot.blaudden
14cfc7e1ba Merge pilot.blaudden:/home/msvensson/mysql/bug20166/my50-bug20166
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
2007-02-27 14:54:33 +01:00
lars/lthalmann@mysql.com/dl145j.mysql.com
1a09fb81fc Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge
2007-02-25 00:10:51 +01:00
lars/lthalmann@mysql.com/dl145h.mysql.com
1777f04e39 Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge
2007-02-24 11:41:31 +01:00
monty@mysql.com/narttu.mysql.fi
e5cc397f33 Fixed compiler warnings (for linux and win32 and win64)
Fixed a couple of usage of not initialized warnings (unlikely cases)
2007-02-22 16:59:57 +02:00
monty@mysql.com/narttu.mysql.fi
26aa385bc5 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2007-02-21 14:07:08 +02:00
kaa@polly.local
b7e6df7cc9 Merge polly.local:/tmp/maint/bug25137/my50-bug25137
into  polly.local:/home/kaa/src/maint/mysql-5.0-maint
2007-02-20 22:23:51 +03:00
msvensson@pilot.blaudden
6caa0a232e Bug#20166 mysql-test-run.pl does not test system privilege tables creation
- Part 2, add @@hostname system variable
2007-02-20 16:24:38 +01:00
kaa@polly.local
315819fed0 Bug#18743: Several test cases fails if "classic" configuration in 5.0
The problem happened because those tests were using "cp932" and "ucs2" without checking whether these character sets are available. This fix moves test parts to make character set specific parts be tested only if they are:
- some parts were moved to "ctype_ucs.test" and "ctype_cp932.test"
- some parts were moved to the newly added tests "innodb-ucs2.test", "mysqlbinglog-cp932.test" and "sp-ucs2.test"
2007-02-19 13:57:06 +03:00
guilhem@gbichot3.local
2f75c9cd69 Backport from the Falcon tree.
When opening/creating the transaction coordinator's log, if binlog is
used, the tc log is the binlog so we use the binlog's name; otherwise
we use the mmap-based log, named after the mandatory argument of the
--log-tc option (meant for that).
2007-02-15 15:50:56 +01:00
msvensson@pilot.mysql.com
24a242bee1 Merge pilot.mysql.com:/home/msvensson/mysql/bug18628/my50-bug18628
into  pilot.mysql.com:/home/msvensson/mysql/mysql-5.0-maint
2007-02-14 14:45:15 +01:00
msvensson@pilot.mysql.com
45fe5879f4 Bug#18628 mysql-test-run: security problem(part1)
- Implement --secure-file-priv=<dir> option that limits
  "load_file", "LOAD DATA" and "SELECT .. INTO OUTFILE" to work 
  with files in specified dir.
 - Use above option for mysqld in mysql-test-run.pl
2007-02-14 14:44:34 +01:00
msvensson@neptunus.(none)
ede3afe470 Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0
into  neptunus.(none):/home/msvensson/mysql/mysql-5.0-maint
2007-02-06 14:45:08 +01:00
msvensson@pilot.mysql.com
256cb08ba9 Merge 192.168.0.10:mysql/mysql-4.1-maint
into  pilot.mysql.com:/home/msvensson/mysql/mysql-4.1-maint
2007-02-06 14:44:05 +01:00
istruewing@chilla.local
77e99fe2ce Merge chilla.local:/home/mydev/mysql-4.1-axmrg
into  chilla.local:/home/mydev/mysql-5.0-axmrg
2007-02-02 23:05:46 +01:00
istruewing@chilla.local
177a366e53 After merge fix 2007-02-02 20:19:13 +01:00
istruewing@chilla.local
33e1d1091a Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into  chilla.local:/home/mydev/mysql-4.1-axmrg
2007-02-01 15:51:25 +01:00
gluh@mysql.com/eagle.(none)
010dc0b55c Valgrind error fixes
Notes:
This patch doesn't fix all issues in the tree and we need jani's fix for that
This patch shoud not be merged into 5.0
2007-02-01 18:00:24 +04:00
istruewing@chilla.local
1c34270464 Merge chilla.local:/home/mydev/mysql-4.1-axmrg
into  chilla.local:/home/mydev/mysql-5.0-axmrg
2007-02-01 10:19:22 +01:00
istruewing@chilla.local
73e61944f7 Merge chilla.local:/home/mydev/mysql-4.0-axmrg
into  chilla.local:/home/mydev/mysql-4.1-axmrg
2007-02-01 08:09:36 +01:00
cmiller@zippy.cornsilk.net
a795b7097f Merge bk-internal.mysql.com:/home/bk/mysql-4.1-maint
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-4.1-maint
2007-01-31 16:26:12 -05:00
cmiller@zippy.cornsilk.net
ad66e7a0dd Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-maint
2007-01-31 16:23:05 -05:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
10dda8e248 Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-4.1-maint
into  mysql.com:/home/ram/work/b19690/b19690.4.1
2007-01-31 14:47:06 +04:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
8da5745858 Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0-maint
into  mysql.com:/home/ram/work/b19690/b19690.5.0
2007-01-31 14:31:11 +04:00
ramil/ram@mysql.com/ramil.myoffice.izhnet.ru
f0f83a36bc Merge mysql.com:/home/ram/work/b19690/b19690.4.1
into  mysql.com:/home/ram/work/b19690/b19690.5.0
2007-01-31 10:07:56 +04:00