Commit graph

120 commits

Author SHA1 Message Date
Nisha Gopalakrishnan
62e8f25677 Bug#11757464:SERVER CRASH IN RECURSIVE CALL WHEN OOM
Analysis:
---------

When the server is out of memory, an error is raised
to indicate the same. Handling the error requires
more memory to be allocated which fails, hence the
error handling loops in a recursion and causes the
server to crash.

Fix:
---
a) Prevents pushing the 'out of memory' error condition
to the diagnostic area as it requires memory allocation.
GET DIAGNOSTICS, SHOW WARNINGS and SHOW ERRORS statements
will not show information about this error. However the
'out of memory' error is returned to the client.
b) It sets the ME_FATALERROR flag when 'out of memory' errors
are reported (for places where the flag is not already set).
This flag prevents activation of SP error handlers which also
require memory allocation and therefore are likely to fail.
2013-01-15 15:30:26 +05:30
Kent Boortz
9da00ebec9 Updated/added copyright headers 2011-06-30 17:46:53 +02:00
Kent Boortz
1400d7a2cc Updated/added copyright headers 2011-06-30 17:37:13 +02:00
Kent Boortz
e5ce023f57 Updated/added copyright headers 2011-06-30 17:31:31 +02:00
Magne Mahre
ebd24626ca Remove configuration preprocessor symbols 'THREAD'
and 'THREAD_SAFE_CLIENT'.
  
As of MySQL 5.5, we no longer support non-threaded
builds.   This patch removes all references to the
obsolete THREAD and THREAD_SAFE_CLIENT preprocessor
symbols.  These were used to distinguish between
threaded and non-threaded builds.
2011-01-11 10:07:37 +01:00
Davi Arnaut
2495e10c11 Merge of mysql-5.1-bugteam into mysql-5.5-bugteam. 2010-11-16 07:45:07 -02:00
Davi Arnaut
80246ac8b8 Bug#58057: 5.1 libmysql/libmysql.c unused variable/compile failure
Bug#57995: Compiler flag change build error on OSX 10.4: my_getncpus.c
Bug#57996: Compiler flag change build error on OSX 10.5 : bind.c
Bug#57994: Compiler flag change build error : my_redel.c
Bug#57993: Compiler flag change build error on FreeBsd 7.0 : regexec.c
Bug#57992: Compiler flag change build error on FreeBsd : mf_keycache.c
Bug#57997: Compiler flag change build error on OSX 10.6: debug_sync.cc

Fix assorted compiler generated warnings.
2010-11-10 19:14:47 -02:00
Davi Arnaut
72fbf95e5d WL#5498: Remove dead and unused source code
Remove the obsolete and buggy bmove512, use memcpy instead.
2010-07-23 17:15:41 -03:00
Davi Arnaut
b3d22cef93 WL#5486: Remove code for unsupported platforms
Remove MS-DOS specific code.
2010-07-15 08:16:06 -03: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
Marc Alff
e33a8b2a1a WL#2360 Performance schema
Part III: mysys instrumentation
2009-12-09 20:19:51 -07:00
Alexander Nozdrin
b930b18ec3 Merge from mysql-5.1. 2009-10-19 17:28:31 +04:00
Joerg Bruehe
5c95f2363a Upmerge the Windows compile fix from 5.0 to 5.1 2009-10-16 15:05:52 +02:00
Joerg Bruehe
0e5dd3712a Upmerge a Windows compile fix from 5.0 to 5.1. 2009-10-16 14:21:20 +02:00
Joerg Bruehe
9ceeabd9b2 Compile fix for Windows:
Use "#ifdef", not plain "#if".
2009-10-16 14:06:33 +02:00
Joerg Bruehe
7a69adf492 Upmerge (automerge) into 5.1 2009-10-09 15:21:45 +02:00
Joerg Bruehe
5184530308 Fix bug#47923 New "mf_keycache.c" requires thread support
The bug is a compilation issue:
Function "find_key_block()" had thread operations
which were not guarded by "#if THREAD", add that now.
2009-10-08 21:58:17 +02:00
Alexander Nozdrin
5b3f34f41e Merge 5.1-bugteam -> trunk-alik. 2009-09-17 22:00:49 +04:00
Georgi Kodinov
59069cac4a fixed compilation warnings 2009-09-24 16:21:46 +03:00
Ingo Struewing
8dcaefca21 Bug#17332 - changing key_buffer_size on a running server
can crash under load

Merge from 5.0, after backport from 5.1/5.4 to 5.0.
This makes the fixes for
Bug 44068 (RESTORE can disable the MyISAM Key Cache)
Bug 40944 (Backup: crash after myisampack)
available to 5.1.
2009-09-09 17:13:13 +02:00
Ingo Struewing
1b60803282 Bug#17332 - changing key_buffer_size on a running server
can crash under load

Backport from 5.1.
Does also include key cache fixes from:
Bug 44068 (RESTORE can disable the MyISAM Key Cache)
Bug 40944 (Backup: crash after myisampack)
2009-09-07 18:35:37 +02:00
Mikael Ronstrom
506c7fd47d Merge MySQL 5.1.35 into MySQL 5.4 2009-06-11 12:07:59 +02:00
Vladislav Vaintroub
57b4295d2b Bug#43932 myisam index corruption with large index and large
key_buffer_size.

The cause of corruption was number overflow when multiplying 
two ulong values, number of used keycache blocks with size
of a single block. The result of multiplication exceeded ulong 
range (4G) and this lead to incorrectly calculated  buffer offset
in the key cache.

The fix is to use size_t for multiplication result.

This patch also fixes pointless cast in safemalloc 
(size of allocated block to uint), that creates lot of false
alarm warnings when using big keycache (> 4GB) in debug mode.
2009-04-29 13:51:10 +02:00
Ignacio Galarza
2d9421c3bb Bug#29125 Windows Server X64: so many compiler warnings
- Remove bothersome warning messages.  This change focuses on the warnings 
that are covered by the ignore file: support-files/compiler_warnings.supp.
- Strings are guaranteed to be max uint in length
2009-02-13 11:41:47 -05:00
Mikael Ronstrom
16a024c486 Backport of DTrace patches from 6.0 2008-12-20 11:01:41 +01:00
Marc Alff
fd324dd3ff Bug#37302 (missing DBUG_RETURN macro in function "find_key_block" (5.0 only))
Fixed missing DBUG_RETURN in the function find_key_block
2008-08-11 15:08:12 -06:00
gkodinov/kgeorge@magare.gmz
dd62320d0e Merge bk-internal:/home/bk/mysql-5.1
into  magare.gmz:/home/kgeorge/mysql/work/merge-build-5.1-bugteam
2008-03-31 10:40:39 +03:00
gkodinov/kgeorge@macbook.gmz
fd9993db87 fixed warnings from the fix of 26243 2008-03-29 17:50:46 +02:00
davi@mysql.com/endora.local
079a174801 Bug#35272: @@global.key_buffer_size = 4294967295 let the server crash
When trying to get the requested amount of memory for the keybuffer,
the out of memory could be signaled if one of the tentative allocations
fail. Later the server would crash (debug assert) when trying to send
a ok packet with a error set.

The solution is only to signal the error if all tentative allocations
for the keybuffer fail.
2008-03-25 15:53:57 -03:00
jani@a88-113-38-195.elisa-laajakaista.fi
4f98f3e683 Merge a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-main
into  a88-113-38-195.elisa-laajakaista.fi:/home/my/bk/mysql-5.1-marvel
2008-02-08 12:13:33 +01:00
kaa@polly.(none)
97226f1027 Merge polly.(none):/home/kaa/src/maint/mysql-5.0-maint
into  polly.(none):/home/kaa/src/maint/mysql-5.1-maint
2007-10-18 14:32:43 +04:00
kaa@polly.(none)
6d1f3e8de5 Fix for bug #31207: Test "join_nested" shows different strategy on IA64
CPUs / Intel's ICC compile

The bug is a combination of two problems:

1. IA64/ICC MySQL binaries use glibc's qsort(), not the one in mysys.

2. The order relation implemented by join_tab_cmp() is not transitive,
i.e. it is possible to choose such a, b and c that (a < b) && (b < c)
but (c < a). This implies that result of a sort using the relation
implemented by join_tab_cmp() depends on the order in which
elements are compared, i.e. the result is implementation-specific. Since
choose_plan() uses qsort() to pre-sort the
join tables using join_tab_cmp() as a compare function, the results of
the sorting may vary depending on qsort() implementation.

It is neither possible nor important to implement a better ordering
algorithm in join_tab_cmp(). Therefore the only way to fix it is to
force our own qsort() to be used by renaming it to my_qsort(), so we don't depend
on linker to decide that.

This patch also "fixes" bug #20530: qsort redefinition violates the
standard.
2007-10-17 20:08:58 +04:00
monty@mysql.com/narttu.mysql.fi
7887babe69 Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1
- Reserver namespace and place in frm for TABLE_CHECKSUM and PAGE_CHECKSUM create options
- Added syncing of directory when creating .frm files
- Portability fixes
- Added missing cast that could cause bugs
- Code cleanups
- Made some bit functions inline
- Moved things out of myisam.h to my_handler.h to make them more accessable
- Renamed some myisam variables and defines to make them more globaly usable (as they are used outside of MyISAM)
- Fixed bugs in error conditions
- Use compiler time asserts instead of run time
- Fixed indentation
HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP as the old name was wrong
(Added a define for old value to ensure we don't break any old code)
Added HA_EXTRA_PREPARE_FOR_RENAME as a signal for rename (before we used a DROP signal which is wrong)
- Initialize error messages early to get better errors when mysqld or an engine fails to start
- Fix windows bug that query_performance_frequency was not initialized if registry code failed
- thread_stack -> my_thread_stack_size
2007-10-11 18:07:40 +03:00
kaa@polly.local
ab0373e78a Backport of the keycache changes from http://lists.mysql.com/commits/31517 to make keycache 64-bit safe in 5.0. This is for bug #5731. 2007-08-29 20:45:04 +04:00
monty@mysql.com/nosik.monty.fi
dd81895e45 Added support for 'internal temporary tables' in HEAP tables.
Now we don't take any mutexes when creating or dropping internal HEAP tables during SELECT.
Change buffer sizes to size_t to make keycache 64 bit safe on platforms where sizeof(ulong) != sizeof(size_t)
2007-07-25 01:58:12 +03:00
istruewing@chilla.local
630450679a Merge chilla.local:/home/mydev/mysql-5.1-amain
into  chilla.local:/home/mydev/mysql-5.1-axmrg
2007-06-11 19:25:12 +02:00
joerg@debian.(none)
b953f1b2c1 Avoid a compile error which arises from a redefinition of "inline":
If it has been defined (by "configure", in "include/my_config.h"),
then an "#undef" is needed to avoid a redefinition.

This is needed to prevent a compile error of the debug server on AIX.
2007-06-01 17:43:48 +02:00
istruewing@chilla.local
8e11f17504 Merge chilla.local:/home/mydev/mysql-5.0-axmrg
into  chilla.local:/home/mydev/mysql-5.1-axmrg
2007-05-31 21:34:05 +02:00
istruewing@chilla.local
59a0542209 Bug#28478 - Improper key_cache_block_size corrupts MyISAM tables
Setting a key_cache_block_size which is not a power of 2
could corrupt MyISAM tables.

A couple of computations in the key cache code use bit
operations which do only work if key_cache_block_size
is a power of 2.

Replaced bit operations by arithmetic operations
to make key cache able to handle block sizes that are
not a power of 2.
2007-05-31 20:04:54 +02:00
jani@linux-th5m.site
f1807e1f25 Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.1
into  linux-th5m.site:/home/my/mysql-5.1-marvel
2007-05-24 15:26:10 +03:00
istruewing@chilla.local
3ed42fbb2d Bug#17332 - changing key_buffer_size on a running server
can crash under load
Post-post-review fixes.
Fixed a typo == -> =
Optimized normal flush at end of statement (FLUSH_KEEP),
but let other flush types be stringent.
Added comments.
Fixed debugging.
2007-05-14 11:33:47 +02:00
monty@mysql.com/narttu.mysql.fi
088e2395f1 WL#3817: Simplify string / memory area types and make things more consistent (first part)
The following type conversions was done:

- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t

Removed declaration of byte, gptr, my_string, my_size_t and size_s. 

Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
  instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
  as this requires fewer casts in the code and is more in line with how the
  standard functions work.
- Added extra length argument to dirname_part() to return the length of the
  created string.
- Changed (at least) following functions to take uchar* as argument:
  - db_dump()
  - my_net_write()
  - net_write_command()
  - net_store_data()
  - DBUG_DUMP()
  - decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
  argument to my_uncompress() from a pointer to a value as we only return
  one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
  the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
  casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.

Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
  needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
  explicitely as this conflict was often hided by casting the function to
  hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
  get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
  size_t. This was needed to properly detect errors (which are
  returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
  (portability fix)
- Removed windows specific code to restore cursor position as this
  causes slowdown on windows and we should not mix read() and pread()
  calls anyway as this is not thread safe. Updated function comment to
  reflect this. Changed function that depended on original behavior of
  my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
  m_size is the number of elements in the array, not a string/memory
  length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
  Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
  - Replaced some calls to alloc_root + memcpy to use
    strmake_root()/strdup_root().
  - Changed some calls from memdup() to strmake() (Safety fix)
  - Simpler loops in client-simple.c
2007-05-10 12:59:39 +03:00
istruewing@chilla.local
942cd7d424 Bug#17332 - changing key_buffer_size on a running server
can crash under load
After review fixes
2007-03-23 11:52:45 +01:00
istruewing@chilla.local
0282c199a0 Merge chilla.local:/home/mydev/mysql-5.1-bug17332-old
into  chilla.local:/home/mydev/mysql-5.1-bug17332
2007-03-20 17:59:09 +01:00
monty@mysql.com/narttu.mysql.fi
f0ae3ce9b9 Fixed compiler warnings
Fixed compile-pentium64 scripts
Fixed wrong estimate of update_with_key_prefix in sql-bench
Merge bk-internal.mysql.com:/home/bk/mysql-5.1 into mysql.com:/home/my/mysql-5.1
Fixed unsafe define of uint4korr()
Fixed that --extern works with mysql-test-run.pl
Small trivial cleanups
This also fixes a bug in counting number of rows that are updated when we have many simultanous queries
Move all connection handling and command exectuion main loop from sql_parse.cc to sql_connection.cc
Split handle_one_connection() into reusable sub functions.
Split create_new_thread() into reusable sub functions.
Added thread_scheduler; Preliminary interface code for future thread_handling code.

Use 'my_thread_id' for internal thread id's
Make thr_alarm_kill() to depend on thread_id instead of thread
Make thr_abort_locks_for_thread() depend on thread_id instead of thread
In store_globals(), set my_thread_var->id to be thd->thread_id.
Use my_thread_var->id as basis for my_thread_name()
The above changes makes the connection we have between THD and threads more soft.

Added a lot of DBUG_PRINT() and DBUG_ASSERT() functions
Fixed compiler warnings
Fixed core dumps when running with --debug
Removed setting of signal masks (was never used)
Made event code call pthread_exit() (portability fix)
Fixed that event code doesn't call DBUG_xxx functions before my_thread_init() is called.
Made handling of thread_id and thd->variables.pseudo_thread_id uniform.
Removed one common 'not freed memory' warning from mysqltest
Fixed a couple of usage of not initialized warnings (unlikely cases)
Suppress compiler warnings from bdb and (for the moment) warnings from ndb
2007-02-23 13:13:55 +02: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
istruewing@chilla.local
48a596edac Bug#17332 - changing key_buffer_size on a running server
can crash under load

Resizing a key cache while it was in heavy use could crash the
server. There were several race conditions.

I reworked some of the algorithms to fix the race conditions.

No test case. Repeating the crashes requires heavy concurrent
load on the key cache. A test script is attached to the bug report.

More explanations to the changes are contained in a text file
attached to the bug report.
2007-01-31 18:49:07 +01:00
monty@narttu.mysql.fi
8a80e36ac3 Merge mysql.com:/home/my/mysql-5.0
into  mysql.com:/home/my/mysql-5.1
Merge of 'remove compiler warnings when using -Wshadow'
2007-01-27 03:46:45 +02:00
monty@mysql.com/narttu.mysql.fi
a04157fbb3 Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into  mysql.com:/home/my/mysql-5.0
2007-01-22 14:04:40 +02:00
kent@kent-amd64.(none)
be15e3bc15 Merge mysql.com:/home/kent/bk/main/mysql-5.0
into  mysql.com:/home/kent/bk/main/mysql-5.1
2006-12-23 20:20:40 +01:00