1. 11 Feb, 2021 1 commit
    • Yossi Gottlieb's avatar
      Fix duplicate replicas issue. (#8481) · 94bc26e6
      Yossi Gottlieb authored
      We need to store replicas referenced by their announced address (IP or
      address). Before that, if hostnames were used and the IP address
      changed, duplicate entries would have been created.
      94bc26e6
  2. 10 Feb, 2021 2 commits
  3. 09 Feb, 2021 3 commits
  4. 08 Feb, 2021 5 commits
  5. 07 Feb, 2021 5 commits
  6. 05 Feb, 2021 3 commits
  7. 04 Feb, 2021 3 commits
  8. 03 Feb, 2021 1 commit
    • Yossi Gottlieb's avatar
      Fix FreeBSD tests and CI Daily issues. (#8438) · de6f3ad0
      Yossi Gottlieb authored
      * Add bash temporarily to allow sentinel fd leaks test to run.
      * Use vmactions-freebsd rdist sync to work around bind permission denied
        and slow execution issues.
      * Upgrade to tcl8.6 to be aligned with latest Ubuntu envs.
      * Concat all command executions to avoid ignoring failures.
      * Skip intensive fuzzer on FreeBSD. For some yet unknown reason, generate_fuzzy_traffic_on_key causes TCL to significantly bloat on FreeBSD resulting with out of memory.
      de6f3ad0
  9. 02 Feb, 2021 3 commits
    • Jonah H. Harris's avatar
      Optimizing sorted GEORADIUS COUNT with partial sorting. (#8326) · a3718cde
      Jonah H. Harris authored
      This commit provides an optimization, in terms of time, for all GEORADIUS*
      and GEOSEARCH* searches which utilize the default, sorted, COUNT clause.
      This is commonly used for nearest-neighbor (top-K points closest to a given lat/lon)
      searches. While the previous implementation appends all matching points to the
      geoPoint array and performs pruning after-the-fact via a full sort and [0, count)-based
      for-loop, this PR sorts only the required number of elements.
      
      This optimization provides a 5-20% improvement in runtime depending on the
      density of points of interest (POI) as well as the radius searched.
      No performance degradation has been observed.
      a3718cde
    • Huang Zw's avatar
      Cleanup: addReplyAggregateLen and addReplyBulkLen remove redundant check (#8431) · 9760475a
      Huang Zw authored
      addReplyLongLongWithPrefix, has a check against negative length, and the code
      flow removed in this commit bypasses the check.
      addReplyAggregateLen has an assertion for negative length, but addReplyBulkLen
      does not, so this commit fixes theoretical case of access violation (probably
      unreachable though)
      9760475a
    • zhaozhao.zz's avatar
      XINFO should use lookupKeyReadOrReply (#8436) · f2a5fe36
      zhaozhao.zz authored
      This bug would have let users observe logically expired keys on replicas and
      during CLIENT PAUSE WRITE.
      f2a5fe36
  10. 31 Jan, 2021 3 commits
  11. 30 Jan, 2021 1 commit
    • Wen Hui's avatar
      fix sentinel tests error (#8422) · eacccd2a
      Wen Hui authored
      This commit fixes sentinel announces hostnames test error in certain linux environment
      Before this commit, we only check localhost is resolved into 127.0.0.1, however in ubuntu
      or some other linux environments "localhost" will be resolved into ::1 ipv6 address first if
      the network stack is capable.
      eacccd2a
  12. 29 Jan, 2021 3 commits
    • filipe oliveira's avatar
      Enabled background and reply time tracking on blocked on keys/blocked on... · f0c5052a
      filipe oliveira authored
      Enabled background and reply time tracking on blocked on keys/blocked on background work clients (#7491)
      
      This commit enables tracking time of the background tasks and on replies,
      opening the door for properly tracking commands that rely on blocking / background
       work via the slowlog, latency history, and commandstats. 
      
      Some notes:
      - The time spent blocked waiting for key changes, or blocked on synchronous
        replication is not accounted for. 
      
      - **This commit does not affect latency tracking of commands that are non-blocking
        or do not have background work.** ( meaning that it all stays the same with exception to
        `BZPOPMIN`,`BZPOPMAX`,`BRPOP`,`BLPOP`, etc... and module's commands that rely
        on background threads ). 
      
      -  Specifically for latency history command we've added a new event class named
        `command-unblocking` that will enable latency monitoring on commands that spawn
        background threads to do the work.
      
      - For blocking commands we're now considering the total time of a command as the
        time spent on call() + the time spent on replying when unblocked.
      
      - For Modules commands that rely on background threads we're now considering the
        total time of a command as the time spent on call (main thread) + the time spent on
        the background thread ( if marked within `RedisModule_MeasureTimeStart()` and
        `RedisModule_MeasureTimeEnd()` ) + the time spent on replying (main thread)
      
      To test for this feature we've added a `unit/moduleapi/blockonbackground` test that relies on
      a module that blocks the client and sleeps on the background for a given time. 
      - check blocked command that uses RedisModule_MeasureTimeStart() is tracking background time
      - check blocked command that uses RedisModule_MeasureTimeStart() is tracking background time even in timeout
      - check blocked command with multiple calls RedisModule_MeasureTimeStart()  is tracking the total background time
      - check blocked command without calling RedisModule_MeasureTimeStart() is not reporting background time
      f0c5052a
    • Yang Bodong's avatar
      Add HRANDFIELD and ZRANDMEMBER. improvements to SRANDMEMBER (#8297) · b9a0500f
      Yang Bodong authored
      
      
      New commands:
      `HRANDFIELD [<count> [WITHVALUES]]`
      `ZRANDMEMBER [<count> [WITHSCORES]]`
      Algorithms are similar to the one in SRANDMEMBER.
      
      Both return a simple bulk response when no arguments are given, and an array otherwise.
      In case values/scores are requested, RESP2 returns a long array, and RESP3 a nested array.
      note: in all 3 commands, the only option that also provides random order is the one with negative count.
      
      Changes to SRANDMEMBER
      * Optimization when count is 1, we can use the more efficient algorithm of non-unique random
      * optimization: work with sds strings rather than robj
      
      Other changes:
      * zzlGetScore: when zset needs to convert string to double, we use safer memcpy (in
        case the buffer is too small)
      * Solve a "bug" in SRANDMEMBER test: it intended to test a positive count (case 3 or
        case 4) and by accident used a negative count
      Co-authored-by: default avatarxinluton <xinluton@qq.com>
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      b9a0500f
    • zhaozhao.zz's avatar
      AOF: recover from last write error after turn on appendonly again (#8030) · 49b36633
      zhaozhao.zz authored
      The key point is how to recover from last AOF write error, for example:
      
      1. start redis with appendonly yes, and append some write commands
      
      2. short write or something else error happen, `server.aof_last_write_status` changed to `C_ERR`, now redis doesn't accept write commands
      
      3. execute `CONFIG SET appendonly no` to avoid the above problem, now redis can accept write commands again
      
      4. disk error resolved, and execute `CONFIG SET appendonly yes` to reopen AOF, but `server.aof_last_write_status` cannot be changed to `C_OK` (if background aof rewrite run less then 1 second, it will free `server.aof_buf` and then serverCron cannot fix `aof_last_write_status`), then redis cannot accept write commands forever.
      
      This PR use a simple way to fix it:
      
      1. just free `server.aof_buf` when stop appendonly to save memory, if error happens in `flushAppendOnlyFile(1)`, the `server.aof_buf` may contains some data which has not be written to aof, I think we can ignore it because we turn off the appendonly.
      
      2. reset fsync status after stop appendonly and call `flushAppendOnlyFile` only when `aof_state` is ON
      
      3. reset `server.last_write_status` when reopen aof to accept write commands
      49b36633
  13. 28 Jan, 2021 7 commits
    • Allen Farris's avatar
      implement FAILOVER command (#8315) · 0d18a1e8
      Allen Farris authored
      Implement FAILOVER command, which coordinates failover
      between the server and one of its replicas.
      0d18a1e8
    • Yossi Gottlieb's avatar
      Update CLIENT HELP regarding KILL options. (#8417) · 26301897
      Yossi Gottlieb authored
      * Indicate address can also be a unix socket path name.
      * Document the LADDR option as well.
      26301897
    • Yossi Gottlieb's avatar
      Add proc-title-template option. (#8397) · 4bb5ccbe
      Yossi Gottlieb authored
      Make it possible to customize the process title, i.e. include custom
      strings, immutable configuration like port, tls-port, unix socket name,
      etc.
      4bb5ccbe
    • guybe7's avatar
      Modules: Add event for fork child birth and termination (#8289) · 01cbf17b
      guybe7 authored
      Useful to avoid doing background jobs that can cause excessive COW
      01cbf17b
    • Wang Yuan's avatar
      Redis exit for fsync error when the AOF fsync policy is 'always' (#8347) · a16739a3
      Wang Yuan authored
      With AOF policy of fsync "always", redis should respect the contract with the user
      that on acknowledged write data is already synced on disk.
      
      Redis was already exiting for AOF write error,  but don't care about fsync failure.
      So to guarantee data safe, redis should exit for fsync error too (when the AOF fsync
      policy is 'always').
      a16739a3
    • Viktor Söderqvist's avatar
      Add modules API for streams (#8288) · 4355145a
      Viktor Söderqvist authored
      APIs added for these stream operations: add, delete, iterate and
      trim (by ID or maxlength). The functions are prefixed by RM_Stream.
      
      * RM_StreamAdd
      * RM_StreamDelete
      * RM_StreamIteratorStart
      * RM_StreamIteratorStop
      * RM_StreamIteratorNextID
      * RM_StreamIteratorNextField
      * RM_StreamIteratorDelete
      * RM_StreamTrimByLength
      * RM_StreamTrimByID
      
      The type RedisModuleStreamID is added and functions for converting
      from and to RedisModuleString.
      
      * RM_CreateStringFromStreamID
      * RM_StringToStreamID
      
      Whenever the stream functions return REDISMODULE_ERR, errno is set to
      provide additional error information.
      
      Refactoring: The zset iterator fields in the RedisModuleKey struct
      are wrapped in a union, to allow the same space to be used for type-
      specific info for streams and allow future use for other key types.
      4355145a
    • Yossi Gottlieb's avatar
      Add hostname support in Sentinel. (#8282) · bb7cd974
      Yossi Gottlieb authored
      
      
      This is both a bugfix and an enhancement.
      
      Internally, Sentinel relies entirely on IP addresses to identify
      instances. When configured with a new master, it also requires users to
      specify and IP and not hostname.
      
      However, replicas may use the replica-announce-ip configuration to
      announce a hostname. When that happens, Sentinel fails to match the
      announced hostname with the expected IP and considers that a different
      instance, triggering reconfiguration, etc.
      
      Another use case is where TLS is used and clients are expected to match
      the hostname to connect to with the certificate's SAN attribute. To
      properly implement this configuration, it is necessary for Sentinel to
      redirect clients to a hostname rather than an IP address.
      
      The new 'resolve-hostnames' configuration parameter determines if
      Sentinel is willing to accept hostnames. It is set by default to no,
      which maintains backwards compatibility and avoids unexpected DNS
      resolution delays on systems with DNS configuration issues.
      
      Internally, Sentinel continues to identify instances by their resolved
      IP address and will also report the IP by default. The new
      'announce-hostnames' parameter determines if Sentinel should prefer to
      announce a hostname, when available, rather than an IP address. This
      applies to addresses returned to clients, as well as their
      representation in the configuration file, REPLICAOF configuration
      commands, etc.
      
      This commit also introduces SENTINEL CONFIG GET and SENTINEL CONFIG SET
      which can be used to introspect or configure global Sentinel
      configuration that was previously was only possible by directly
      accessing the configuration file and possibly restarting the instance.
      Co-authored-by: default avatarmyl1024 <myl92916@qq.com>
      Co-authored-by: default avatarsundb <sundbcn@gmail.com>
      bb7cd974