1. 12 Feb, 2014 1 commit
    • antirez's avatar
      AOF: don't abort on write errors unless fsync is 'always'. · fadbbdd3
      antirez authored
      A system similar to the RDB write error handling is used, in which when
      we can't write to the AOF file, writes are no longer accepted until we
      are able to write again.
      
      For fsync == always we still abort on errors since there is currently no
      easy way to avoid replying with success to the user otherwise, and this
      would violate the contract with the user of only acknowledging data
      already secured on disk.
      fadbbdd3
  2. 03 Feb, 2014 2 commits
    • antirez's avatar
      Move mstime_t define outside sentinel.c. · ddcf1603
      antirez authored
      The define is now used in other parts of Redis 2.8 tree instead of long
      long.
      
      A nice side effect is that now 2.8 and unstable sentinel.c files are
      identical as it should be.
      ddcf1603
    • antirez's avatar
      Scripting: use mstime() and mstime_t for lua_time_start. · 3da5cbe5
      antirez authored
      server.lua_time_start is expressed in milliseconds. Use mstime_t instead
      of long long, and populate it with mstime() instead of ustime()/1000.
      
      Functionally identical but more natural.
      3da5cbe5
  3. 31 Jan, 2014 2 commits
  4. 14 Jan, 2014 1 commit
  5. 08 Jan, 2014 1 commit
    • antirez's avatar
      Don't send REPLCONF ACK to old masters. · 2a1a31ca
      antirez authored
      Masters not understanding REPLCONF ACK will reply with errors to our
      requests causing a number of possible issues.
      
      This commit detects a global replication offest set to -1 at the end of
      the replication, and marks the client representing the master with the
      REDIS_PRE_PSYNC flag.
      
      Note that this flag was called REDIS_PRE_PSYNC_SLAVE but now it is just
      REDIS_PRE_PSYNC as it is used for both slaves and masters starting with
      this commit.
      
      This commit fixes issue #1488.
      2a1a31ca
  6. 19 Dec, 2013 1 commit
  7. 11 Dec, 2013 1 commit
  8. 10 Dec, 2013 2 commits
    • antirez's avatar
      Slaves heartbeats during sync improved. · 563d6b3f
      antirez authored
      The previous fix for false positive timeout detected by master was not
      complete. There is another blocking stage while loading data for the
      first synchronization with the master, that is, flushing away the
      current data from the DB memory.
      
      This commit uses the newly introduced dict.c callback in order to make
      some incremental work (to send "\n" heartbeats to the master) while
      flushing the old data from memory.
      
      It is hard to write a regression test for this issue unfortunately. More
      support for debugging in the Redis core would be needed in terms of
      functionalities to simulate a slow DB loading / deletion.
      563d6b3f
    • antirez's avatar
      dict.c: added optional callback to dictEmpty(). · b6610a56
      antirez authored
      Redis hash table implementation has many non-blocking features like
      incremental rehashing, however while deleting a large hash table there
      was no way to have a callback called to do some incremental work.
      
      This commit adds this support, as an optiona callback argument to
      dictEmpty() that is currently called at a fixed interval (one time every
      65k deletions).
      b6610a56
  9. 03 Dec, 2013 1 commit
  10. 28 Nov, 2013 1 commit
  11. 21 Nov, 2013 3 commits
  12. 05 Nov, 2013 1 commit
    • antirez's avatar
      SCAN code refactored to parse cursor first. · 060d56e7
      antirez authored
      The previous implementation of SCAN parsed the cursor in the generic
      function implementing SCAN, SSCAN, HSCAN and ZSCAN.
      
      The actual higher-level command implementation only checked for empty
      keys and return ASAP in that case. The result was that inverting the
      arguments of, for instance, SSCAN for example and write:
      
          SSCAN 0 key
      
      Instead of
      
          SSCAN key 0
      
      Resulted into no error, since 0 is a non-existing key name very likely.
      Just the iterator returned no elements at all.
      
      In order to fix this issue the code was refactored to extract the
      function to parse the cursor and return the error. Every higher level
      command implementation now parses the cursor and later checks if the key
      exist or not.
      060d56e7
  13. 29 Oct, 2013 4 commits
  14. 06 Aug, 2013 3 commits
    • antirez's avatar
      Add per-db average TTL information in INFO output. · fa48b1fa
      antirez authored
      Example:
      
      db0:keys=221913,expires=221913,avg_ttl=655
      
      The algorithm uses a running average with only two samples (current and
      previous). Keys found to be expired are considered at TTL zero even if
      the actual TTL can be negative.
      
      The TTL is reported in milliseconds.
      fa48b1fa
    • antirez's avatar
      Some activeExpireCycle() refactoring. · 00c8cfef
      antirez authored
      00c8cfef
    • antirez's avatar
      Draft #1 of a new expired keys collection algorithm. · 500155b9
      antirez authored
      The main idea here is that when we are no longer to expire keys at the
      rate the are created, we can't block more in the normal expire cycle as
      this would result in too big latency spikes.
      
      For this reason the commit introduces a "fast" expire cycle that does
      not run for more than 1 millisecond but is called in the beforeSleep()
      hook of the event loop, so much more often, and with a frequency bound
      to the frequency of executed commnads.
      
      The fast expire cycle is only called when the standard expiration
      algorithm runs out of time, that is, consumed more than
      REDIS_EXPIRELOOKUPS_TIME_PERC of CPU in a given cycle without being able
      to take the number of already expired keys that are yet not collected
      to a number smaller than 25% of the number of keys.
      
      You can test this commit with different loads, but a simple way is to
      use the following:
      
      Extreme load with pipelining:
      
      redis-benchmark -r 100000000 -n 100000000  \
              -P 32 set ele:rand:000000000000 foo ex 2
      
      Remove the -P32 in order to avoid the pipelining for a more real-world
      load.
      
      In another terminal tab you can monitor the Redis behavior with:
      
      redis-cli -i 0.1 -r -1 info keyspace
      
      and
      
      redis-cli --latency-history
      
      Note: this commit will make Redis printing a lot of debug messages, it
      is not a good idea to use it in production.
      500155b9
  15. 16 Jul, 2013 1 commit
  16. 12 Jul, 2013 2 commits
    • antirez's avatar
      SORT ALPHA: use collation instead of binary comparison. · 18fabeb2
      antirez authored
      Note that we only do it when STORE is not used, otherwise we want an
      absolutely locale independent and binary safe sorting in order to ensure
      AOF / replication consistency.
      
      This is probably an unexpected behavior violating the least surprise
      rule, but there is currently no other simple / good alternative.
      18fabeb2
    • antirez's avatar
      Fixed compareStringObject() and introduced collateStringObject(). · d8fcbb66
      antirez authored
      compareStringObject was not always giving the same result when comparing
      two exact strings, but encoded as integers or as sds strings, since it
      switched to strcmp() when at least one of the strings were not sds
      encoded.
      
      For instance the two strings "123" and "123\x00456", where the first
      string was integer encoded, would result into the old implementation of
      compareStringObject() to return 0 as if the strings were equal, while
      instead the second string is "greater" than the first in a binary
      comparison.
      
      The same compasion, but with "123" encoded as sds string, would instead
      return a value < 0, as it is correct. It is not impossible that the
      above caused some obscure bug, since the comparison was not always
      deterministic, and compareStringObject() is used in the implementation
      of skiplists, hash tables, and so forth.
      
      At the same time, collateStringObject() was introduced by this commit, so
      that can be used by SORT command to return sorted strings usign
      collation instead of binary comparison. See next commit.
      d8fcbb66
  17. 11 Jul, 2013 4 commits
    • antirez's avatar
      getClientPeerId() refactored into two functions. · 3472d045
      antirez authored
      3472d045
    • antirez's avatar
      getClientPeerId() now reports errors. · da183666
      antirez authored
      We now also use it in CLIENT KILL implementation.
      da183666
    • antirez's avatar
      getClientPeerID introduced. · 4fa68b28
      antirez authored
      The function returns an unique identifier for the client, as ip:port for
      IPv4 and IPv6 clients, or as path:0 for Unix socket clients.
      
      See the top comment in the function for more info.
      4fa68b28
    • Geoff Garside's avatar
      Add macro to define clusterNode.ip buffer size. · 68d72aa5
      Geoff Garside authored
      Add REDIS_CLUSTER_IPLEN macro to define the size of the clusterNode ip
      character array. Additionally use this macro in inet_ntop(3) calls where
      the size of the array was being defined manually.
      
      The REDIS_CLUSTER_IPLEN is defined as INET_ADDRSTRLEN which defines the
      correct size of a buffer to store an IPv4 address in. The
      INET_ADDRSTRLEN macro itself is defined in the <netinet/in.h> header
      file and should be portable across the majority of systems.
      68d72aa5
  18. 08 Jul, 2013 2 commits
  19. 01 Jul, 2013 1 commit
  20. 26 Jun, 2013 6 commits
    • antirez's avatar
      bb0d0fd4
    • antirez's avatar
      Don't disconnect pre PSYNC replication clients for timeout. · cdf79c06
      antirez authored
      Clients using SYNC to replicate are older implementations, such as
      redis-cli --slave, and are not designed to acknowledge the master with
      REPLCONF ACK commands, so we don't have any feedback and should not
      disconnect them on timeout.
      cdf79c06
    • antirez's avatar
      Use the RSC to replicate EVALSHA unmodified. · 545fe0c3
      antirez authored
      This commit uses the Replication Script Cache in order to avoid
      translating EVALSHA into EVAL whenever possible for both the AOF and
      slaves.
      545fe0c3
    • antirez's avatar
      Replication of scripts as EVALSHA: sha1 caching implemented. · 9d894b1b
      antirez authored
      This code is only responsible to take an LRU-evicted fixed length cache
      of SHA1 that we are sure all the slaves received.
      
      In this commit only the implementation is provided, but the Redis core
      does not use it to actually send EVALSHA to slaves when possible.
      9d894b1b
    • antirez's avatar
      New API to force propagation. · 8328d993
      antirez authored
      The old REDIS_CMD_FORCE_REPLICATION flag was removed from the
      implementation of Redis, now there is a new API to force specific
      executions of a command to be propagated to AOF / Replication link:
      
          void forceCommandPropagation(int flags);
      
      The new API is also compatible with Lua scripting, so a script that will
      execute commands that are forced to be propagated, will also be
      propagated itself accordingly even if no change to data is operated.
      
      As a side effect, this new design fixes the issue with scripts not able
      to propagate PUBLISH to slaves (issue #873).
      8328d993
    • antirez's avatar
      PUBSUB command implemented. · a8f1474d
      antirez authored
      Currently it implements three subcommands:
      
      PUBSUB CHANNELS [<pattern>]    List channels with non-zero subscribers.
      PUBSUB NUMSUB [channel_1 ...]  List number of subscribers for channels.
      PUBSUB NUMPAT                  Return number of subscribed patterns.
      a8f1474d