1. 12 Dec, 2022 11 commits
    • DarrenJiang13's avatar
      fix the client type in trackingInvalidateKey() (#11052) · ec5564a4
      DarrenJiang13 authored
      Fix bug with scripts ignoring client tracking NOLOOP and
      send an invalidation message anyway.
      
      (cherry picked from commit 44859a41)
      ec5564a4
    • Huang Zhw's avatar
      tracking pending invalidation message of flushdb sent by (#11068) · 2cd5f6f3
      Huang Zhw authored
      trackingHandlePendingKeyInvalidations should use proto.
      
      (cherry picked from commit 61451b02)
      2cd5f6f3
    • Huang Zhw's avatar
      When client tracking is on, invalidation message of flushdb in a (#11038) · fbcd591b
      Huang Zhw authored
      When FLUSHDB / FLUSHALL / SWAPDB is inside MULTI / EXEC, the
      client side tracking invalidation message was interleaved with transaction response.
      
      (cherry picked from commit 6f0a27e3)
      fbcd591b
    • Meir Shpilraien (Spielrein)'s avatar
      Fix #11030, use lua_rawget to avoid triggering metatables and crash. (#11032) · e1b17f12
      Meir Shpilraien (Spielrein) authored
      Fix #11030, use lua_rawget to avoid triggering metatables.
      
      #11030 shows how return `_G` from the Lua script (either function or eval), cause the
      Lua interpreter to Panic and the Redis processes to exit with error code 1.
      Though return `_G` only panic on Redis 7 and 6.2.7, the underline issue exists on older
      versions as well (6.0 and 6.2). The underline issue is returning a table with a metatable
      such that the metatable raises an error.
      
      The following example demonstrate the issue:
      ```
      127.0.0.1:6379> eval "local a = {}; setmetatable(a,{__index=function() foo() end}) return a" 0
      Error: Server closed the connection
      ```
      ```
      PANIC: unprotected error in call to Lua API (user_script:1: Script attempted to access nonexistent global variable 'foo')
      ```
      
      The Lua panic happened because when returning the result to the client, Redis needs to
      introspect the returning table and transform the table into a resp. In order to scan the table,
      Redis uses `lua_gettable` api which might trigger the metatable (if exists) and might raise an error.
      This code is not running inside `pcall` (Lua protected call), so raising an error causes the
      Lua to panic and exit. Notice that this is not a crash, its a Lua panic that exit with error code 1.
      
      Returning `_G` panics on Redis 7 and 6.2.7 because on those versions `_G` has a metatable
      that raises error when trying to fetch a none existing key.
      
      ### Solution
      
      Instead of using `lua_gettable` that might raise error and cause the issue, use `lua_rawget`
      that simply return the value from the table without triggering any metatable logic.
      This is promised not to raise and error.
      
      The downside of this solution is that it might be considered as breaking change, if someone
      rely on metatable in the returned value. An alternative solution is to wrap this entire logic
      with `pcall` (Lua protected call), this alternative require a much bigger refactoring.
      
      ### Back Porting
      
      The same fix will work on older versions as well (6.2, 6.0). Notice that on those version,
      the issue can cause Redis to crash if inside the metatable logic there is an attempt to accesses
      Redis (`redis.call`). On 7.0, there is not crash and the `redis.call` is executed as if it was done
      from inside the script itself.
      
      ### Tests
      
      Tests was added the verify the fix
      
      (cherry picked from commit 020e046b)
      e1b17f12
    • chenyang8094's avatar
      Register abs-expire apis (#11025) · 8c76e0f2
      chenyang8094 authored
      RM_SetAbsExpire and RM_GetAbsExpire were not actually operational since
      they were introduced, due to omission in API registration.
      
      (cherry picked from commit 39d216a3)
      8c76e0f2
    • Yossi Gottlieb's avatar
      TLS: Notify clients on connection shutdown. (#10931) · b4de9e83
      Yossi Gottlieb authored
      Use SSL_shutdown(), in a best-effort manner, when closing a TLS
      connection. This change better supports OpenSSL 3.x clients that will
      not silently ignore the socket-level EOF.
      
      (cherry picked from commit 45ae6053)
      b4de9e83
    • Oran Agra's avatar
      optimize zset conversion on large ZRANGESTORE (#10789) · 70aaf500
      Oran Agra authored
      when we know the size of the zset we're gonna store in advance,
      we can check if it's greater than the listpack encoding threshold,
      in which case we can create a skiplist from the get go, and avoid
      converting the listpack to skiplist later after it was already populated.
      
      (cherry picked from commit 21891003)
      70aaf500
    • Oran Agra's avatar
      crash report instructions (#10816) · 66472a5e
      Oran Agra authored
      Trying to avoid people opening crash report issues about module crashes and ARM QEMU bugs.
      
      (cherry picked from commit 475563e2)
      66472a5e
    • Vitaly's avatar
      Fix ZRANGESTORE crash when zset_max_listpack_entries is 0 (#10767) · fd7bde57
      Vitaly authored
      When `zrangestore` is called container destination object is created.
      Before this PR we used to create a listpack based object even if `zset-max-ziplist-entries`
      or equivalent`zset-max-listpack-entries` was set to 0.
      This triggered immediate conversion of the listpack into a skiplist in `zrangestore`, which hits
      an assertion resulting in an engine crash.
      
      Added a TCL test that reproduces this issue.
      
      (cherry picked from commit 6461f09f)
      fd7bde57
    • Madelyn Olson's avatar
      Unpause clients earlier during manual cluster failover (#9676) · 9d40f1cb
      Madelyn Olson authored
      Unpause clients after manual failover ends instead of the timed offset
      
      (cherry picked from commit 32215e78)
      9d40f1cb
    • Wen Hui's avatar
      Sentinel: don't log auth-pass value for better security (#9652) · 389c5e14
      Wen Hui authored
      (cherry picked from commit 43b22f17)
      389c5e14
  2. 06 Dec, 2022 1 commit
    • Meir Shpilraien (Spielrein)'s avatar
      Remove dead code on sorting reply on Lua scripts. (#10701) · 64c657a8
      Meir Shpilraien (Spielrein) authored
      On v6.2.7 a new mechanism was added to Lua scripts that allows
      filtering the globals of the Lua interpreter. This mechanism was
      added on the following commit: https://github.com/redis/redis/commit/11b602fbf8f9cdf8fc741c24625ab6287ab998a9
      
      One of the globals that was filtered out was `__redis__compare_helper`. This global
      was missed and was not added to the allow list or to the deny list. This is
      why we get the following warning when Redis starts:
      `A key '__redis__compare_helper' was added to Lua globals which is not on the globals allow list nor listed on the deny list.`
      
      After investigating the git blame log, the conclusion is that `__redis__compare_helper`
      is no longer needed, the PR deletes this function, and fixes the warning.
      
      Detailed Explanation:
      
      `__redis__compare_helper` was added on this commit: https://github.com/redis/redis/commit/2c861050c1
      Its purpose is to sort the replies of `SORT` command when script replication is enable and keep the replies
      deterministic and avoid primary and replica synchronization issues. On `SORT` command, there was a need for
      special compare function that are able to compare boolean values.
      
      The need to sort the `SORT` command reply was removed on this commit: https://github.com/redis/redis/commit/36741b2c818a95e8ef167818271614ee6b1bc414
      The sorting was moved to be part of the `SORT` command and there was not longer a need
      to sort it on the Lua interpreter. The commit made `__redis__compare_helper` a dead code but did
      not deleted it.
      64c657a8
  3. 27 Apr, 2022 28 commits