Commit Graph

51 Commits

Author SHA1 Message Date
antirez
6fdc635447 Better Out of Memory handling.
The previous implementation of zmalloc.c was not able to handle out of
memory in an application-specific way. It just logged an error on
standard error, and aborted.

The result was that in the case of an actual out of memory in Redis
where malloc returned NULL (In Linux this actually happens under
specific overcommit policy settings and/or with no or little swap
configured) the error was not properly logged in the Redis log.

This commit fixes this problem, fixing issue #509.
Now the out of memory is properly reported in the Redis log and a stack
trace is generated.

The approach used is to provide a configurable out of memory handler
to zmalloc (otherwise the default one logging the event on the
standard output is used).
2012-08-24 12:55:37 +02:00
antirez
ee789e157c Dump ziplist hex value on failed assertion.
The ziplist -> hashtable conversion code is triggered every time an hash
value must be promoted to a full hash table because the number or size of
elements reached the threshold.

If a problem in the ziplist causes the same field to be present
multiple times, the assertion of successful addition of the element
inside the hash table will fail, crashing server with a failed
assertion, but providing little information about the problem.

This code adds a new logging function to perform the hex dump of binary
data, and makes sure that the ziplist -> hashtable conversion code uses
this new logging facility to dump the content of the ziplist when the
assertion fails.

This change was originally made in order to investigate issue #547.
2012-06-12 00:41:48 +02:00
antirez
61daf8914d Impovements for: Redis timer, hashes rehashing, keys collection.
A previous commit introduced REDIS_HZ define that changes the frequency
of calls to the serverCron() Redis function. This commit improves
different related things:

1) Software watchdog: now the minimal period can be set according to
REDIS_HZ. The minimal period is two times the timer period, that is:

    (1000/REDIS_HZ)*2 milliseconds

2) The incremental rehashing is now performed in the expires dictionary
as well.

3) The activeExpireCycle() function was improved in different ways:

- Now it checks if it already used too much time using microseconds
  instead of milliseconds for better precision.
- The time limit is now calculated correctly, in the previous version
  the division was performed before of the multiplication resulting in
  a timelimit of 0 if HZ was big enough.
- Databases with less than 1% of buckets fill in the hash table are
  skipped, because getting random keys is too expensive in this
  condition.

4) tryResizeHashTables() is now called at every timer call, we need to
   match the number of calls we do to the expired keys colleciton cycle.

5) REDIS_HZ was raised to 100.
2012-05-13 21:52:35 +02:00
antirez
11bd247d2b Produce the stack trace in an async safe way. 2012-04-26 16:28:54 +02:00
antirez
a66a496349 Fix and refactoring of code used to get registers on crash.
This fixes compilation on FreeBSD (and possibly other systems) by
not using ucontext_t at all if HAVE_BACKTRACE is not defined.
Also the ifdefs to get the registers are modified to explicitly test for the
operating system in the first level, and the arch in the second level
of nesting.
2012-04-24 11:11:35 +02:00
Premysl Hruby
8918de9202 remove mentions of VM in comments 2012-04-02 11:56:03 +02:00
antirez
a7d12cbaf1 Log from signal handlers is now safer. 2012-03-28 13:45:39 +02:00
antirez
23c0cdd2ad Produce the watchlog warning log in a way that is safer from a signal handler. Fix a memory leak in the backtrace generation function. 2012-03-27 15:24:33 +02:00
antirez
a354da9acd Correctly set the SIGARLM timer for the software watchdog. 2012-03-27 12:11:37 +02:00
antirez
39bd025c29 Redis software watchdog. 2012-03-27 11:47:51 +02:00
antirez
a323870450 SIGSEGV handler refactored so that we can reuse stack trace and current client logging functionalities in other contexts. 2012-03-27 10:40:07 +02:00
antirez
525be599a8 On crash suggest to give --test-memory a try. 2012-03-18 11:35:35 +01:00
Pieter Noordhuis
57be47758e Also force SIGSEGV without HAVE_BACKTRACE 2012-02-21 10:20:01 -08:00
antirez
ac834d237a A few small BSD related fixes. 2012-02-08 22:24:59 +01:00
antirez
a48c8d873b Fix for hash table collision attack. We simply randomize hash table initialization value at startup time. 2012-01-21 23:30:13 +01:00
antirez
447ebf3bc7 Better looking registers/stack dump 2012-01-20 16:40:43 +01:00
antirez
632da60583 added support to dump registers on crash on Linux x32 2012-01-20 14:37:50 +01:00
antirez
eea8c7a4f8 added support to dump registers on crash on Linux x64 2012-01-20 12:54:15 +01:00
antirez
d4d208595c all the stack trace related functions are now in debug.c. Now Redis dumps registers and stack content on crash. Currently osx supported, adding Linux right now. 2012-01-20 12:20:45 +01:00
antirez
00010fa96f On crash print information about the current client (if any), command vector, and object associated to first argument assuming it is a key. 2012-01-12 16:02:57 +01:00
antirez
f48cd4b90c some RDB server struct fields renamed. 2011-12-21 12:22:13 +01:00
antirez
2c915bcf6d AOF fileds in the global server state, and define names, renamed with more consistent names. More work to do. 2011-12-21 11:58:42 +01:00
antirez
efb6022529 Do not propagate DEBUG LOADAOF 2011-12-20 17:52:57 +01:00
antirez
fa5af017d9 better bug report info on crash 2011-11-24 15:47:26 +01:00
antirez
4be855e757 Fixed issues with expire introduced with latest millisecond resolution feature. Many time_t were not converted to long long, and one time() call was not replaced with mstime(). 2011-11-12 01:04:27 +01:00
antirez
c0ba9ebe13 dict.c API names modified to be more coincise and consistent. 2011-11-08 17:07:55 +01:00
antirez
80ad7189e8 More informative error when DEBUG RELOAD fails. 2011-10-14 14:31:33 +02:00
antirez
bab205f787 redisAssertWithClientInfo() is now redisAssertWithInfo() that is also able to report an optional object. The client is also optional. Specifying NULL will prevent dumping the not available information (either client or object). 2011-10-04 18:05:26 +02:00
antirez
e3e6993510 Introduced a redisAssert() variant that is able to show information about the client in the context where the failed assertion was detected. 2011-10-04 17:22:29 +02:00
antirez
404345d8e5 DEUBG SLEEP implemented 2011-06-30 13:31:44 +02:00
antirez
c9d0c3623a diskstore removed 2011-06-25 12:22:03 +02:00
antirez
f13cb0d9de DEBUG DIGEST additional lookup needed for VM removed from unstable branch that does not have VM at all 2011-05-10 10:08:01 +02:00
Pieter Noordhuis
100ed062c0 Test for ENCODING_SKIPLIST instead of ENCODING_RAW 2011-04-06 16:17:07 +02:00
Pieter Noordhuis
dddf5335f4 Fix DEBUG DIGEST, SORT and AOF rewrite 2011-03-14 13:30:06 +01:00
antirez
a5062bbab0 fixed bgsave_in_progress in INFO when BGSAVEing with diskstore enabled, don't DEBUG FLUSHCACHE when bgsave is in progress. 2011-01-09 19:25:34 +01:00
antirez
0a0f83ab2c DEBUG FLUSHCACHE needs to wait that everything was synched on disk 2011-01-09 19:01:44 +01:00
antirez
69bfffb4a7 test adapted to run with diskstore, and a few bugs fixed 2011-01-09 18:25:34 +01:00
antirez
b39619d8e7 DEBUG OBJECT fixed with diskstore, force loading 2011-01-08 02:06:01 +01:00
antirez
120b9ba8f8 FLUSHALL / FLUSHDB for diskstore implemented 2011-01-03 10:17:39 +01:00
antirez
3be00d7ed6 implemented a different approach to IO scheduling, so object->storage is no longer used, instead there is a queue and hash table of IO tasks to process, and it is always possible to know what are the scheduled and acrtive IO operations against every single key. 2011-01-01 21:35:56 +01:00
antirez
5ef640986b more step forwards for disk store to be able to run 2010-12-29 16:58:57 +01:00
antirez
8c304be359 cow friendly HGETALL and variants 2010-12-14 12:10:51 +01:00
antirez
1b508da7ca SINTER/MEMBERS are now COW friendly, also some refactoring around was needed to get this result. 2010-12-09 23:01:09 +01:00
Pieter Noordhuis
bd70a5f588 Stop using /dev/null to find out the serialized object length
Now the rdbSave* functions return the number of bytes written (or
required to write) in serializing a Redis object, writing to /dev/null
and using ftell (which doesn't work on FreeBSD) isn't needed anymore.
2010-11-21 16:31:27 +01:00
antirez
1de98301f6 removed useless spaces from DEBUG OBJECT output 2010-10-27 17:11:17 +02:00
antirez
ef59a8bc9e Object approximated LRU algorithm enhanced / fixed / refactored. This is used for the VM currently but will soon be used for maxmemory expiring. 2010-10-14 13:52:58 +02:00
Pieter Noordhuis
3ab203762f Use specialized function to add status and error replies 2010-09-02 23:33:06 +02:00
Pieter Noordhuis
cb72d0f155 Rename iterator to setTypeIterator for consistency 2010-08-21 11:38:24 +02:00
Pieter Noordhuis
2767f1c0c6 fix aof and digest code to work with dual set encoding 2010-07-02 20:42:20 +02:00
antirez
3688d7f308 Compilation fixed on Linux after the source code split 2010-07-01 21:13:38 +02:00