53 Commits

Author SHA1 Message Date
antirez
022bd293a6 Fast memory test on Redis crash. 2012-11-21 13:24:44 +01:00
antirez
a32d1ddff6 BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
antirez
9b0b9ed3c3 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
58125f6ebc 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
2b103500e9 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
df581b92db Produce the stack trace in an async safe way. 2012-04-26 16:28:54 +02:00
antirez
d70f60dbb7 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
efae255bb0 remove mentions of VM in comments 2012-04-02 11:56:03 +02:00
antirez
740f77af69 Log from signal handlers is now safer. 2012-03-28 13:45:39 +02:00
antirez
1b060d2658 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
469dfe73f2 Correctly set the SIGARLM timer for the software watchdog. 2012-03-27 12:11:37 +02:00
antirez
25d500767a Redis software watchdog. 2012-03-27 11:47:51 +02:00
antirez
81e00d1596 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
28d36fd045 On crash suggest to give --test-memory a try. 2012-03-18 11:35:35 +01:00
Pieter Noordhuis
ad7797988d Also force SIGSEGV without HAVE_BACKTRACE 2012-02-21 10:20:01 -08:00
antirez
3fcae1cc78 A few small BSD related fixes. 2012-02-08 22:24:59 +01:00
antirez
fff238e507 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
95e3043515 Better looking registers/stack dump 2012-01-20 16:40:43 +01:00
antirez
ddf4019e3b added support to dump registers on crash on Linux x32 2012-01-20 14:37:50 +01:00
antirez
113adf562c added support to dump registers on crash on Linux x64 2012-01-20 12:54:15 +01:00
antirez
df25feb732 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
a9ea3f0700 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
4aa527ba09 some RDB server struct fields renamed. 2011-12-21 12:22:13 +01:00
antirez
9868316d3f 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
ca9ba394ca Do not propagate DEBUG LOADAOF 2011-12-20 17:52:57 +01:00
antirez
6bf13b1a8e better bug report info on crash 2011-11-24 15:47:26 +01:00
antirez
c93ee2bcad 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
d6c3b3004e dict.c API names modified to be more coincise and consistent. 2011-11-08 17:07:55 +01:00
antirez
3ef6c840cf More informative error when DEBUG RELOAD fails. 2011-10-14 14:31:33 +02:00
antirez
3e622d2c1d 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
9f58a0880d 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
0849d05e30 DEUBG SLEEP implemented 2011-06-30 13:31:44 +02:00
antirez
59f09141f5 diskstore removed 2011-06-25 12:22:03 +02:00
antirez
5f25487ec4 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
a6ca3077d4 Test for ENCODING_SKIPLIST instead of ENCODING_RAW 2011-04-06 16:17:07 +02:00
Pieter Noordhuis
3746a4135a Fix DEBUG DIGEST, SORT and AOF rewrite 2011-03-14 13:30:06 +01:00
antirez
d3aa7312b9 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
819b03213f DEBUG FLUSHCACHE needs to wait that everything was synched on disk 2011-01-09 19:01:44 +01:00
antirez
f261a5d500 test adapted to run with diskstore, and a few bugs fixed 2011-01-09 18:25:34 +01:00
antirez
2e31c54134 DEBUG OBJECT fixed with diskstore, force loading 2011-01-08 02:06:01 +01:00
antirez
4d5369b25d FLUSHALL / FLUSHDB for diskstore implemented 2011-01-03 10:17:39 +01:00
antirez
db52125d45 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
71c9187472 more step forwards for disk store to be able to run 2010-12-29 16:58:57 +01:00
antirez
a2a232690a cow friendly HGETALL and variants 2010-12-14 12:10:51 +01:00
antirez
3cb849b6be 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
e127bd9c53 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
93d2466d19 removed useless spaces from DEBUG OBJECT output 2010-10-27 17:11:17 +02:00
antirez
4c1af00e16 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