1. 22 Feb, 2021 1 commit
  2. 21 Feb, 2021 3 commits
    • Yossi Gottlieb's avatar
      Fix allowed length for REPLCONF ip-address. (#8517) · d828f90c
      Yossi Gottlieb authored
      Originally this was limited to IPv6 address length, but effectively it
      has been used for host names and now that Sentinel accepts that as well
      we need to be able to store full hostnames.
      
      Fixes #8507
      d828f90c
    • Huang Zw's avatar
      Client tracking tracking-redir-broken push len is 2 not 3 (#8456) · f687ac0c
      Huang Zw authored
      When redis responds with tracking-redir-broken push message (RESP3),
      it was responding with a broken protocol: an array of 3 elements, but only
      pushes 2 elements.
      
      Some bugs in the test make this pass. Read the push reply
      will consume an extra reply, because the reply length is 3, but there
      are only two elements, so the next reply will be treated as third
      element. So the test is corrected too.
      
      Other changes:
      * checkPrefixCollisionsOrReply success should return 1 instead of -1,
        this bug didn't have any implications.
      * improve client tracking tests to validate more of the response it reads.
      f687ac0c
    • Gnanesh's avatar
      EXPIRE, EXPIREAT, SETEX, GETEX: Return error when expire time overflows (#8287) · 0772098b
      Gnanesh authored
      
      
      Respond with error if expire time overflows from positive to negative of vice versa.
      
      * `SETEX`, `SET EX`, `GETEX` etc would have already error on negative value,
      but now they would also error on overflows (i.e. when the input was positive but
      after the manipulation it becomes negative, which would have passed before)
      * `EXPIRE` and `EXPIREAT` was ok taking negative values (would implicitly delete
      the key), we keep that, but we do error if the user provided a value that changes
      sign when manipulated (except the case of changing sign when `basetime` is added)
      Signed-off-by: default avatarGnanesh <gnaneshkunal@outlook.com>
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      0772098b
  3. 20 Feb, 2021 1 commit
    • Jim Brunner's avatar
      dict: pause rehash, minor readability refactor (#8515) · 06966d2a
      Jim Brunner authored
      The `dict` field `iterators` is misleading and incorrect. 
      This variable is used for 1 purpose - to pause rehashing.
      
      The current `iterators` field doesn't actually count "iterators".
      It counts "safe iterators".  But - it doesn't actually count safe iterators
      either.  For one, it's only incremented once the safe iterator begins to
      iterate, not when it's created.  It's also incremented in `dictScan` to
      prevent rehashing (and commented to make it clear why `iterators` is
      being incremented during a scan).
      
      This update renames the field as `pauserehash` and creates 2 helper
      macros `dictPauseRehashing(d)` and `dictResumeRehashing(d)`
      06966d2a
  4. 17 Feb, 2021 2 commits
  5. 16 Feb, 2021 5 commits
  6. 15 Feb, 2021 3 commits
  7. 14 Feb, 2021 1 commit
  8. 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
  9. 10 Feb, 2021 2 commits
  10. 09 Feb, 2021 2 commits
  11. 08 Feb, 2021 3 commits
  12. 07 Feb, 2021 2 commits
    • Oran Agra's avatar
      Optimize HRANDFIELD and ZRANDMEMBER case 4 when ziplist encoded (#8444) · 62b1f320
      Oran Agra authored
      
      
      It is inefficient to repeatedly pick a single random element from a
      ziplist.
      For CASE4, which is when the user requested a low number of unique
      random picks from the collectoin, we used thta pattern.
      
      Now we use a different algorithm that picks unique elements from a
      ziplist, and guarentee no duplicate but doesn't provide random order
      (which is only needed in the non-unique random picks case)
      
      Unrelated changes:
      * change ziplist count and indexes variables to unsigned
      * solve compilation warnings about uninitialized vars in gcc 10.2
      Co-authored-by: default avatarxinluton <xinluton@qq.com>
      62b1f320
    • Yossi Gottlieb's avatar
      Add --insecure option to command line tools. (#8416) · be83bb13
      Yossi Gottlieb authored
      Disable certificate validation, making it possible to connect to servers
      without configuring full trust chain.
      
      The use of this option is insecure and makes the connection vulnerable
      to man in the middle attacks.
      be83bb13
  13. 05 Feb, 2021 2 commits
    • Viktor Söderqvist's avatar
      RM_ZsetRem: Delete key if empty (#8453) · aea6e71e
      Viktor Söderqvist authored
      Without this fix, RM_ZsetRem can leave empty sorted sets which are
      not allowed to exist.
      
      Removing from a sorted set while iterating seems to work (while
      inserting causes failed assetions). RM_ZsetRangeEndReached is
      modified to return 1 if the key doesn't exist, to terminate
      iteration when the last element has been removed.
      aea6e71e
    • sundb's avatar
      RAND* commands: fix risk of OOM panic in hash and zset, use fair random in... · 18ac4197
      sundb authored
      
      RAND* commands: fix risk of OOM panic in hash and zset, use fair random in hash, and add tests for even distribution to all (#8429)
      
      Changes to HRANDFIELD and ZRANDMEMBER:
      * Fix risk of OOM panic when client query a very big negative count (avoid allocating huge temporary buffer).
      * Fix uneven random distribution in HRANDFIELD with negative count (wasn't using dictGetFairRandomKey).
      * Add tests to check an even random distribution (HRANDFIELD, SRANDMEMBER, ZRANDMEMBER).
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      18ac4197
  14. 04 Feb, 2021 1 commit
    • Yang Bodong's avatar
      GEOSEARCH bybox bug fixes and new fuzzy tester (#8445) · ded1655d
      Yang Bodong authored
      
      
      Fix errors of GEOSEARCH bybox search due to:
      1. projection of the box to a trapezoid (when the meter box is converted to long / lat it's no longer a box).
      2. width and height mismatch
      
      Changes:
      - New GEOSEARCH point in rectangle algorithm
      - Fix GEOSEARCH bybox width and height mismatch bug
      - Add GEOSEARCH bybox testing to the existing "GEOADD + GEORANGE randomized test"
      - Add new fuzzy test to stress test the bybox corners and edges
      - Add some tests for edge cases of the bybox algorithm
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      ded1655d
  15. 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
  16. 31 Jan, 2021 2 commits
    • Oran Agra's avatar
      update help.h with new commands (#8426) · b57d0eb4
      Oran Agra authored
      b57d0eb4
    • Oran Agra's avatar
      Fix test issues from introduction of HRANDFIELD (#8424) · 5a7eb9c8
      Oran Agra authored
      * The corrupt dump fuzzer found a division by zero.
      * in some cases the random fields from the HRANDFIELD tests produced
        fields with newlines and other special chars (due to \ char), this caused
        the TCL tests to see a bulk response that has a newline in it and add {}
        around it, later it can think this is a nested list. in fact the `alpha` random
        string generator isn't using spaces and newlines, so it should not use `\`
        either.
      5a7eb9c8
  17. 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
  18. 28 Jan, 2021 3 commits