Commit graph

68 commits

Author SHA1 Message Date
Christopher Powers
49667f0441 Bug#21374104 SETUP_TIMERS INITIALIZATION ASSUMES CYCLE TIMER IS ALWAYS AVAILABLE
For WAIT events, fall back to other timers if CYCLE is not available.
2015-07-10 20:42:33 +02:00
Murthy Narkedimilli
42bfa90874 Updated/added copyright header. Added line "use is subject to license terms"
to copyright header.
2014-02-17 18:19:04 +05:30
Ritheesh Vedire
44c56d37df Bug#16814264: FILTER OUT THE PERFORMANCE_SCHEMA RELAY LOG EVENTS FROM RELAY LOG
Performance schema tables are local to a server and they should not
  be allowed to be executed by the slave from the relay log.
  From 5.6.10, P_S events are not written into the binary log.
  But prior to that, from mysql 5.5 onwards, P_S events are written 
  to the binary log by master.
  The following are problematic scenarios:
      
  1. Master 5.5 -> Slave 5.5
     ========================
    A) RBR: Slave crashes
    B) SBR: P_S statements are replicated.
      
  2.Master 5.5 -> Slave 5.6
    ========================
    A) RBR: SQL thd generates error
    B) SBR : P_S statements are replicated
      
  3. 5.5 binlog executed on a server 5.5 using mysqlbinlog|mysql
     =================================================================
     A) RBR: Server crash  (because of BINLOG'... statement)
     B) SBR: P_S statements are executed
      
  4. 5.5 binlog executed on server 5.6 using mysqlbinlog|mysql
     ================================================================
     A) RBR: SQL error (because of BINLOG'... statement)
     B) SBR: P_S statements are executed.
      
      
    The generalized behaviour should be:
    a) Slave SQL thread should certainly ignore P_S events read from
       the relay log.
    b) mysqlbinlog|mysql should replay the binlog succesfully.
2014-01-31 04:25:39 +05:30
Murthy Narkedimilli
496abd0814 Updated/added copyright headers 2014-01-06 10:52:35 +05:30
Marc Alff
b734cd73ff Bug#17928281 'CHECK_PERFORMANCE_SCHEMA()' LEAVES 'CURRENT_THD' REFERRING
DESTRUCTED THD OBJ 

Prior to fix, function check_performance_schema() could leave
behind stale pointers in thread local storage, for the following keys:
- THR_THD (used by _current_thd)
- THR_MALLOC (used for memory allocation)
This is an unsafe practice, which can potentially cause crashes,
and that can cause other bugs when code is modified during maintenance.

With this fix, thread local storage keys used temporarily within
function check_performance_schema() are cleaned up after use.
2013-12-11 11:15:23 +01:00
Murthy Narkedimilli
d978016d93 Fix for Bug 16395495 - OLD FSF ADDRESS IN GPL HEADER 2013-03-19 15:53:48 +01:00
Marc Alff
fafa23dcc2 Bug#16414644 ASSERTION FAILED: SIZE == PFS_ALLOCATED_MEMORY
Before this fix, the command
  SHOW ENGINE PERFORMANCE_SCHEMA STATUS
could report wrong amount of memory allocated,
when the amount of memory used exceeds 4GB.

The problem is that size computations are not done using size_t,
so that overflows do occur, truncating the results.

This fix compute memory sizes properly with size_t.

Tested manually.

No test script provided, as the script would need to allocate too much 
memory for the test.
2013-02-28 13:19:15 +01:00
Marc Alff
7a84630765 Bug#16060864 SEGMENTATION FAULT IN PERFORMANCE_SCHEMA WITH HISTORY SIZE 0
Before this fix, configuring the server with:
- performance_schema_events_waits_history_size=0
- performance_schema_events_waits_history_long_size=0
could cause a crash in the performance schema.

These settings to 0 are intended to be valid and supported,
and are in fact working properly in mysql 5.6 and up already.

This fix backports the code fix and test cases from mysql 5.6
to the mysql 5.5 release.
2013-01-02 11:00:55 +01:00
Marc Alff
ea40710d0e Bug#13898343 THREAD LOOPS ENDLESSLY IN LF_PINBOX_PUT_PINS WHILE HOLDING
LOCK_THREAD_COUNT

When using the performance schema file io instrumentation in MySQL 5.5,
a thread would loop forever inside lf_pinbox_put_pins, when disconnecting.
It would also hold LOCK_thread_count while doing so, effectively killing the
server.

The root cause of the loop in lf_pinbox_put_pins() is a leak of LF_PINS,
when used with the filename_hash LF_HASH table in the performance schema.

This fix contains the following changes:

1)
Added the missing call to lf_hash_search_unpin(), to prevent the leak.

2)
In mysys/lf_alloc-pin.c, there was some extra debugging code
(MY_LF_EXTRA_DEBUG) written to detect precisely this kind of issues,
but it was never used.
Replaced MY_LF_EXTRA_DEBUG with DBUG_OFF, so that leaks similar to this one
can be always detected in regular debug builds.

3)
Backported the fix for the following bug, from 5.6 to 5.5:
Bug#13417446 - 63339: INCORRECT FILE PATH IN PEFORMANCE_SCHEMA ON WINDOWS
2012-03-28 17:54:30 +02:00
MySQL Build Team
5734bae576 Updated/added copyright headers 2012-02-16 10:48:16 +01:00
Mats Kindahl
ee789c28b4 Merging into mysql-5.5.16-release. 2011-08-15 20:12:11 +02:00
Davi Arnaut
017281da24 Bug#12727287: Maintainer mode compilation fails with gcc 4.6
GCC 4.6 has new -Wunused-but-set-variable flag, which is enabled
by -Wall, that causes GCC to emit a warning whenever a local variable
is assigned to, but otherwise unused (aside from its declaration).

Since the maintainer mode uses -Wall and -Werror, source code which
triggers these warnings will be rejected. That is, these warnings
become hard errors.

The solution is to fix the code which triggers these specific warnings.
In most of the cases, this is a welcome cleanup as code which triggers
this warning is probably dead anyway.
2011-07-07 08:22:43 -03:00
Kent Boortz
9da00ebec9 Updated/added copyright headers 2011-06-30 17:46:53 +02:00
Marc Alff
627707e2f8 Bug#11830755 - UNIT TESTS PFS_INSTR AND PFS_INSTR_CLASS CRASH IN MUTEX CALLS ON WINDOWS
Before this fix, two performance schema unit tests crashed on windows.

The problem was a missing initialization to PFS_atomics,
which caused the crash only for platform not compiled with native atomics.

This fix adds the missing initialization in the unit tests.
No production code was changed, this is a unit test bug only.
2011-03-08 13:42:00 +01:00
Tor Didriksen
f482437cdc Bug #58699 cannot build with gcc dbg on solaris 2010-12-21 13:00:26 +01:00
Marc Alff
537366fd24 Bug#58798 SHOW ENGINE PERFORMANCE_SCHEMA STATUS: incorrect table lettercase
Before this fix, the output of SHOW ENGINE PERFORMANCE_SCHEMA STATUS
used uppercase to name performance schema tables.

This is inconsistent since performance schema tables have been renamed to lowercase.

Also, an old table 'PROCESSLIST' was still visible, 
even after this table got renamed to 'threads'.

This fix:
- correctly uses lowercases in the output, to match the current naming.
- replaced 'PROCESSLIST' with 'threads'.

Tested the output of SHOW ENGINE PERFORMANCE_SCHEMA STATUS manually.
No automated test cases can be written for this, 
since the output is too platform dependent (sizes).
2010-12-07 21:00:33 +01:00
Marc Alff
033c6c394d Bug#53696 Performance schema engine violates the PSEA API by calling my_error()
This is a code cleanup.

The implementation of a storage engine (subclasses of handler) is not supposed
to call my_error() directly inside the engine implementation, 
but only return error codes, and report errors later at the demand
of the sql layer only (if needed), using handler::print_error().

This fix removes misplaced calls to my_error(),
and provide an implementation of print_error() instead.

Given that the sql layer implementation of create table, ha_create_table(),
does not use print_error() but returns ER_CANT_CREATE_TABLE directly,
the return code for create table statements using the performance schema
has changed to ER_CANT_CREATE_TABLE.

Adjusted the test suite accordingly.
2010-12-01 13:06:41 +01:00
Marc Alff
218ca24cd9 local merge 2010-11-21 14:32:48 +01:00
Davi Arnaut
f6deb00a56 WL#5665: Removal of the autotools-based build system
The autotools-based build system has been superseded and
is being removed in order to ease the maintenance burden on
developers tweaking and maintaining the build system.

In order to support tools that need to extract the server
version, a new file that (only) contains the server version,
called VERSION, is introduced. The file contents are human
and machine-readable. The format is:

MYSQL_VERSION_MAJOR=5
MYSQL_VERSION_MINOR=5
MYSQL_VERSION_PATCH=8
MYSQL_VERSION_EXTRA=-rc

The CMake based version extraction in cmake/mysql_version.cmake
is changed to extract the version from this file. The configure
to CMake wrapper is retained for backwards compatibility and to
support the BUILD/ scripts. Also, a new a makefile target
show-dist-name that prints the server version is introduced.
2010-11-20 12:47:50 -02:00
Marc Alff
8afd96e4d4 Bug#56760 PFS_lock::allocated_to_free() assert failures on osx10.5-x86-64bit
Before this fix, an assert could fail in PFS_lock::allocated_to_free(), during shutdown.
The assert itself is valid, and detects an anomaly caused by bug 56666.

While bug 56666 has no real consequences in production,
the failure caused by this new assert in the code is negatively
impacting the test suite with automated tests.

This fix is a work around only, that relaxes the integrity checks 
during the server shutdown.
2010-11-16 09:36:42 +01:00
Marc Alff
d47af174be Bug#58003 Segfault on CHECKSUM TABLE performance_schema.EVENTS_WAITS_HISTORY_LONG EXTENDED
This fix is a follow up on the fix for similar issue 56761.

When sanitizing data read from the events_waits_history_long table,
the code needs also to sanitize the schema_name / object_name / file_name pointers,
because such pointers could also hold invalid values.
Checking the string length alone was required but not sufficient.

This fix verifies that:
- the table schema and table name used in table io events
- the file name used in file io events
are valid pointers before dereferencing these pointers.
2010-11-11 12:34:46 +01:00
Marc Alff
7f35b15ada Bug#57609 performance_schema does not work with lower_case_table_names
Before this fix, the performance schema tables were defined in UPPERCASE.

This was incompatible with the lowercase_table_names option, and caused
issues with the install / upgrade process, when changing the lower case
table names setting *after* the install or upgrade.

With this fix, all performance schema tables are exposed with lowercase names.
As a result, the name of the performance schema table is always lowercase,
no matter how / if / when the lowercase_table_names setting if changed.
2010-11-03 16:42:33 +01:00
Marc Alff
2a4f50a5df local merge 2010-10-26 11:02:32 +02:00
Marc Alff
4c929d53fa Bug#57154 Rename THREADS.ID to THREADS.PROCESSLIST_ID in 5.5
This change is to align the 5.5 performance_schema.THREADS
table definition with the 5.6 performance_schema.THREADS table,
to facilitate the 5.5 -> 5.6 migration later.

In the table performance_schema.THREADS:
- renamed ID to PROCESSLIST_ID, removed not null
- changed NAME from varchar(64) to varchar(128)
to match the columns definitions from 5.6

Adjusted the test cases accordingly.

Note: this fix is for 5.5 only, to null merge into 5.6
2010-10-06 18:03:27 -06:00
Davi Arnaut
5f911fa874 Bug#49938: Failing assertion: inode or deadlock in fsp/fsp0fsp.c
Bug#54678: InnoDB, TRUNCATE, ALTER, I_S SELECT, crash or deadlock

- Incompatible change: truncate no longer resorts to a row by
row delete if the storage engine does not support the truncate
method. Consequently, the count of affected rows does not, in
any case, reflect the actual number of rows.

- Incompatible change: it is no longer possible to truncate a
table that participates as a parent in a foreign key constraint,
unless it is a self-referencing constraint (both parent and child
are in the same table). To work around this incompatible change
and still be able to truncate such tables, disable foreign checks
with SET foreign_key_checks=0 before truncate. Alternatively, if
foreign key checks are necessary, please use a DELETE statement
without a WHERE condition.

Problem description:

The problem was that for storage engines that do not support
truncate table via a external drop and recreate, such as InnoDB
which implements truncate via a internal drop and recreate, the
delete_all_rows method could be invoked with a shared metadata
lock, causing problems if the engine needed exclusive access
to some internal metadata. This problem originated with the
fact that there is no truncate specific handler method, which
ended up leading to a abuse of the delete_all_rows method that
is primarily used for delete operations without a condition.

Solution:

The solution is to introduce a truncate handler method that is
invoked when the engine does not support truncation via a table
drop and recreate. This method is invoked under a exclusive
metadata lock, so that there is only a single instance of the
table when the method is invoked.

Also, the method is not invoked and a error is thrown if
the table is a parent in a non-self-referencing foreign key
relationship. This was necessary to avoid inconsistency as
some integrity checks are bypassed. This is inline with the
fact that truncate is primarily a DDL operation that was
designed to quickly remove all data from a table.
2010-10-06 11:34:28 -03:00
Marc Alff
fa4c505eda Bug#50557 checksum table crashes server when used in performance_schema
CHECKSUM TABLE for performance schema tables could cause uninitialized
memory reads.

The root cause is a design flaw in the implementation of
mysql_checksum_table(), which do not honor null fields.

However, fixing this bug in CHECKSUM TABLE is risky, as it can cause the
checksum value to change.

This fix implements a work around, to systematically reset fields values
even for null fields, so that the field memory representation is always
initialized with a known value.
2010-09-17 13:03:09 -06:00
Marc Alff
2e4717ffcd Bug#56761 Segfault on CHECKSUM TABLE performance_schema.EVENTS_WAITS_HISTORY EXTENDED
Before this fix, the server could crash inside a memcpy when reading data
from the EVENTS_WAITS_CURRENT / HISTORY / HISTORY_LONG  tables.

The root cause is that the length used in a memcpy could be corrupted,
when another thread writes data in the wait record being read.
Reading unsafe data is ok, per design choice, and the code does sanitize
the data in general, but did not sanitize the length given to memcpy.

The fix is to also sanitize the schema name / object name / file name
length when extracting the data to produce a row.
2010-09-15 12:20:48 -06:00
Tor Didriksen
197a2dba30 Header files should be self-contained 2010-09-10 11:10:38 +02:00
Marc Alff
c9ab025dcd Bug#56521 Assertion failed: (m_state == 2), function allocated_to_free, pfs_lock.h (138)
Before this fix, it was possible to build the server:
- with the performance schema
- with a dummy implementation of my_atomic (MY_ATOMIC_MODE_DUMMY).

In this case, the resulting binary will just crash,
as this configuration is not supported.

This fix enforces that the build will fail with a compilation error in this
configuration, instead of resulting in a broken binary.
2010-09-09 14:28:47 -06:00
Marc Alff
7357081989 local merge 2010-08-27 15:23:37 -06:00
Christopher Powers
f84adb9ec8 Bug# 53874 "SETUP_INSTRUMENTS.TIMED='NO' should not change TIMER_WAIT
Handle combined instrument states of ENABLED and/or TIMED:

ENABLED TIMED
1 1 Aggregate stats, increment counter
1 0 Increment counter
0 1 Do nothing
0 0 Do nothing
2010-08-26 10:45:25 -05:00
Marc Alff
d2df3a8ac5 Bug#55576 Two perfschema tests failed on mysql-next-mr-innodb PB2 tests
Before this fix, some tests failed due to lack of instrumentation slots
in the performance schema, because the default sizing was too low.

Now that more code has been instrumented, the default sizing has to be adjusted
to match the current instrumentation consumption.

This change:
- increases the number of rwlock classes from 20 to 30,
- increases the number of rwlock and mutex instances to 1 million.
Both are to account for the volume of data instrumented
when the innodb storage engine is used (because of the innodb buffer pool).

Adjusted the test output accordingly.
2010-08-24 18:21:43 -06:00
Christopher Powers
e2b3529413 Bug#53874, "SETUP_INSTRUMENTS.TIMED='NO' should not change TIMER_WAIT in aggregations"
end_*_wait() functions now honor TIMER_STATE_UNTIMED
2010-08-19 17:24:07 -05:00
Marc Alff
7dd4600850 Bug#55416 Renaming of performance_schema tables for 5.5
Removed table SETUP_OBJECTS.
      
Renamed table PROCESSLIST to THREADS.
      
Renamed table EVENTS_WAITS_SUMMARY_BY_EVENT_NAME
to EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME.
      
Adjusted Makefiles, code and tests accordingly.
2010-08-12 08:08:52 -06:00
Marc Alff
5c85a9388a Bug#55462 Performance schema: reduce the overhead of PFS_events_waits::m_wait_class
This is a performance improvement fix.

Removed the "volatile" property of PFS_events_waits::m_wait_class.
Simplified the code accordingly.
2010-08-12 03:51:58 -06:00
Davi Arnaut
e81506971f WL#5498: Remove dead and unused source code
Remove workarounds for ancient systems.
2010-07-23 17:17:55 -03:00
Davi Arnaut
dd14fa18af WL#5498: Remove dead and unused source code
Remove unused variables.
2010-07-23 17:13:36 -03:00
Marc Alff
edf7865437 Bug#52134 performance schema file io, symlink in path
Backport from mysql-next-mr (5.6) to mysql-trunk (5.5)
2010-07-15 19:25:03 -06:00
Marc Alff
c92a6ea8ea Bug#53617 Missing performance schema tables not reported in the server log at startup
Backport from mysql-next-mr (5.6) to mysql-trunk (5.5)
2010-07-15 19:18:44 -06:00
Marc Alff
772a7172dc Bug#52502 Performance schema does not start with large mutex_instance buffers
Backport from mysql-next-mr (5.6) to mysql-trunk (5.5)
2010-07-15 19:03:08 -06:00
Marc Alff
a809475699 Bug#52586 Misleading error message on attempt to access a P_S table using a wrong name
Backport from mysql-next-mr (5.6) to mysql-trunk (5.5)
2010-07-15 18:50:39 -06:00
Marc Alff
9f27e28976 Bug#53566 SHOW ENGINE PERFORMANCE_SCHEMA STATUS reports less memory than really used
Backporting the fix from myql-next-mr (5.6) to mysql-trunk (5.5)
2010-07-15 18:28:52 -06:00
Marc Alff
f16681d614 Bug#53148 Remove PFS_readonly_table
This fix is for cleanup, to resolve a remaining code review item.
Backport from mysql-next-mr (5.6) to mysql-trunk (5.5).
2010-07-15 18:06:33 -06:00
Marc Alff
bb9505ae31 Fixed Copyright headers in storage/perfschema
Fixed minor merge issues with #includes
2010-07-15 17:44:45 -06:00
Marc Alff
6090cbe552 Bug#55087 Performance schema: optimization of the instrumentation interface
This change is for performance optimization.

Fixed the performance schema instrumentation interface as follows:
- simplified mysql_unlock_mutex()
- simplified mysql_unlock_rwlock()
- simplified mysql_cond_signal()
- simplified mysql_cond_broadcast()

Changed the get_thread_XXX_locker apis to have one extra parameter,
to provide memory to the instrumentation implementation.
This API change allows to use memory provided by the caller,
to avoid having to use thread local storage.
Using this extra parameter will be done in a separate fix,
this change is for the interface only.

Adjusted all the code and unit tests accordingly.
2010-07-09 17:00:24 -06:00
Davi Arnaut
a10ae35328 Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.

Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.

Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost. 

The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.

Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
2010-07-08 18:20:08 -03:00
Davi Arnaut
5dec0c9637 Bug#53445: Build with -Wall and fix warnings that it generates
Fix various mismatches between function's language linkage. Any
particular function that is declared in C++ but should be callable
from C must have C linkage. Note that function types with different
linkages are also distinct. Thus, if a function type is declared in
C code, it will have C linkage (same if declared in a extern "C"
block).
2010-05-31 12:29:54 -03:00
Vladislav Vaintroub
04b601a7fe Fix perfschema unittests build on Windows
pthread_t is not defined unless my_pthread.h is included.
2010-04-13 13:48:46 +02:00
Marc Alff
7decb1b928 Bug#52754 Build break in mysql-trunk, performance schema unit test
Tree cleaup after the last major merges in mysql-trunk:

The files sql/lex_hash.h and sql/sql_yacc.h are automatically
generated, and should not be checked in the configuration management system.
These files are now removed.
No changes are required for .bzrignore, which already listed these files
(and similar files in libmysqld/).

The file storage/perfschema/unittest/pfs_timer-t.cc did not build
after the header files refactoring affecting mysql_priv.h
The file now builds properly using sql_priv.h
2010-04-12 03:31:45 -06:00
Mats Kindahl
2c79d4d02b WL#5030: Splitting mysql_priv.h
Adding include to build on Windows.
2010-04-06 23:00:01 +02:00