1. 12 Dec, 2022 39 commits
    • ranshid's avatar
      fix test Migrate the last slot away from a node using redis-cli (#11221) · e1557e6c
      ranshid authored
      When using cli to add node, there can potentially be a race condition in
      which all nodes presenting cluster state o.k even though the added node
      did not yet meet all cluster nodes.
      this adds another utility function to wait until all cluster nodes see the same cluster size
      
      (cherry picked from commit c0ce97fa)
      e1557e6c
    • Binbin's avatar
      Fix timing issue in cluster test (#11008) · b5784fea
      Binbin authored
      A timing issue like this was reported in freebsd daily CI:
      ```
      *** [err]: Sanity test push cmd after resharding in tests/unit/cluster/cli.tcl
      Expected 'CLUSTERDOWN The cluster is down' to match '*MOVED*'
      ```
      
      We additionally wait for each node to reach a consensus on the cluster
      state in wait_for_condition to avoid the cluster down error.
      
      The fix just like #10495, quoting madolson's comment:
      Cluster check just verifies the the config state is self-consistent,
      waiting for cluster_state to be okay is an independent check that all
      the nodes actually believe each other are healthy.
      
      At the same time i noticed that unit/moduleapi/cluster.tcl has an exact
      same test, may have the same problem, also modified it.
      
      (cherry picked from commit 5ce64ab0)
      b5784fea
    • Binbin's avatar
      Fix CLUSTERDOWN issue in cluster reshard unblock test (#11139) · a43c51b2
      Binbin authored
      change the cluster-node-timeout from 1 to 1000
      
      (cherry picked from commit 3a16ad30)
      a43c51b2
    • David CARLIER's avatar
      Fixes build warning when CACHE_LINE_SIZE is already defined. (#11389) · d86408b7
      David CARLIER authored
      * Fixes build warning when CACHE_LINE_SIZE is already defined
      * Fixes wrong CACHE_LINE_SIZE on some FreeBSD systems where it could be set to 128 (e.g. on MIPS)
      * Fixes wrong CACHE_LINE_SIZE on Apple M1 (use 128 instead of 64)
      
      Wrong cache line size in that case can some false sharing of array elements between threads, see #10892
      
      (cherry picked from commit 871cc200)
      d86408b7
    • Oran Agra's avatar
      Avoid ASAN test errors on crash report tests · dca63da4
      Oran Agra authored
      Clang Address Sanitizer tests started reporting unknown-crash on these
      tests due to the memcheck, disable the memcheck to avoid that noise.
      
      (cherry picked from commit 18ff6a3269a34b9bfe549b34bda9d83c3eae7e2a)
      dca63da4
    • Oran Agra's avatar
      Try to fix a race in psync2 test (#11553) · 4a5aba16
      Oran Agra authored
      This test sets the master ping interval to 1 hour, in order to avoid
      pings in the replicatoin stream incrementing the replication offset,
      however, it didn't increase the repl-timeout so on slow machines
      where the test took more than 60 seconds, the replicas would drop
      and reconnect.
      
      ```
      *** [err]: PSYNC2: Partial resync after restart using RDB aux fields in tests/integration/psync2.tcl
      Replica didn't partial sync
      ```
      
      The test would detect 4 additional partial syncs where it expects
      only one.
      
      (cherry picked from commit b0250b45)
      4a5aba16
    • Binbin's avatar
      Bump vmactions/freebsd-vm to 0.3.0 to fix FreeBSD daily (#11476) · 72759356
      Binbin authored
      Our FreeBSD daily has been failing recently:
      ```
        Config file: freebsd-13.1.conf
        cd: /Users/runner/work/redis/redis: No such file or directory
        gmake: *** No targets specified and no makefile found.  Stop.
      ```
      
      Upgrade vmactions/freebsd-vm to the latest version (0.3.0) can work.
      I've tested it, but don't know why, but first let's fix it.
      
      (cherry picked from commit 5246bf45)
      72759356
    • Binbin's avatar
      Fix bgsaveerr issue in psync wrong offset test (#11043) · 98410d0d
      Binbin authored
      The kill above is sometimes successful and sometimes already too late.
      The PING in pysnc wrong offset test got rejected by bgsaveerr because
      lastbgsave_status is C_ERR.
      
      In theory, using diskless can avoid PING being affected, because when
      the replica is dropped, we will kill the child with SIGUSR1, and this
      will not affect lastbgsave_status.
      
      Anyway, this kill is not particularly needed here, dropping the kill
      is the best one, since we do have the waitForBgsave, so just let it
      take care of the bgsave. No need for fast termination.
      
      (cherry picked from commit e7144693)
      98410d0d
    • filipe oliveira's avatar
      Reduce rewriteClientCommandVector usage on EXPIRE command (#11602) · 9ccb8dfd
      filipe oliveira authored
      
      
      There is overhead on Redis 7.0 EXPIRE command that is not present on 6.2.7.
      
      We could see that on the unstable profile there are around 7% of CPU cycles
      spent on rewriteClientCommandVector that are not present on 6.2.7.
      This was introduced in #8474.
      This PR reduces the overhead by using 2X rewriteClientCommandArgument instead of
      rewriteClientCommandVector. In this scenario rewriteClientCommandVector creates 4 arguments.
      the above usage of rewriteClientCommandArgument reduces the overhead in half.
      
      This PR should also improve PEXPIREAT performance by avoiding at all
      rewriteClientCommandArgument usage.
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      (cherry picked from commit c3fb48da)
      9ccb8dfd
    • Harkrishn Patro's avatar
      Optimize client memory usage tracking operation while client eviction is disabled (#11348) · 05c9378b
      Harkrishn Patro authored
      
      
      ## Issue
      During the client input/output buffer processing, the memory usage is
      incrementally updated to keep track of clients going beyond a certain
      threshold `maxmemory-clients` to be evicted. However, this additional
      tracking activity leads to unnecessary CPU cycles wasted when no
      client-eviction is required. It is applicable in two cases.
      
      * `maxmemory-clients` is set to `0` which equates to no client eviction
        (applicable to all clients)
      * `CLIENT NO-EVICT` flag is set to `ON` which equates to a particular
        client not applicable for eviction.
      
      ## Solution
      * Disable client memory usage tracking during the read/write flow when
        `maxmemory-clients` is set to `0` or `client no-evict` is `on`.
        The memory usage is tracked only during the `clientCron` i.e. it gets
        periodically updated.
      * Cleanup the clients from the memory usage bucket when client eviction
        is disabled.
      * When the maxmemory-clients config is enabled or disabled at runtime,
        we immediately update the memory usage buckets for all clients (tested
        scanning 80000 took some 20ms)
      
      Benchmark shown that this can improve performance by about 5% in
      certain situations.
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      (cherry picked from commit c0267b3f)
      05c9378b
    • Binbin's avatar
      Fix command line startup --sentinel problem (#11591) · b322a77e
      Binbin authored
      There is a issue with --sentinel:
      ```
      [root]# src/redis-server sentinel.conf --sentinel --loglevel verbose
      
      *** FATAL CONFIG FILE ERROR (Redis 255.255.255) ***
      Reading the configuration file, at line 352
      >>> 'sentinel "--loglevel" "verbose"'
      Unrecognized sentinel configuration statement
      ```
      
      This is because in #10660 (Redis 7.0.1), `--` prefix change break it.
      In this PR, we will handle `--sentinel` the same as we did for `--save`
      in #10866. i.e. it's a pseudo config option with no value.
      
      (cherry picked from commit 8f13ac10)
      b322a77e
    • filipe oliveira's avatar
      GEOSEARCH BYBOX: Simplified haversine distance formula when longitude diff is 0 (#11579) · 5e02338e
      filipe oliveira authored
      This is take 2 of `GEOSEARCH BYBOX` optimizations based on haversine
      distance formula when longitude diff is 0.
      The first one was in #11535 .
      
      - Given longitude diff is 0 the asin(sqrt(a)) on the haversine is asin(sin(abs(u))).
      - arcsin(sin(x)) equal to x when x ∈[−𝜋/2,𝜋/2].
      - Given latitude is between [−𝜋/2,𝜋/2] we can simplifiy arcsin(sin(x)) to x.
      
      On the sample dataset with 60M datapoints, we've measured 55% increase
      in the achievable ops/sec.
      
      (cherry picked from commit e48ac075)
      5e02338e
    • filipe oliveira's avatar
      Reintroduce lua argument cache in luaRedisGenericCommand removed in v7.0 (#11541) · 6a6d8806
      filipe oliveira authored
      This mechanism aims to reduce calls to malloc and free when
      preparing the arguments the script sends to redis commands.
      This is a mechanism was originally implemented in 48c49c48
      and 4f686555
      
      , and was removed in #10220 (thinking it's not needed
      and that it has no impact), but it now turns out it was wrong, and it
      indeed provides some 5% performance improvement.
      
      The implementation is a little bit too simplistic, it assumes consecutive
      calls use the same size in the same arg index, but that's arguably
      sufficient since it's only aimed at caching very small things.
      
      We could even consider always pre-allocating args to the full
      LUA_CMD_OBJCACHE_MAX_LEN (64 bytes) rather than the right size for the argument,
      that would increase the chance they'll be able to be re-used.
      But in some way this is already happening since we're using
      sdsalloc, which in turn uses s_malloc_usable and takes ownership
      of the full side of the allocation, so we are padded to the allocator
      bucket size.
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      Co-authored-by: default avatarsundb <sundbcn@gmail.com>
      (cherry picked from commit 2d80cd78)
      6a6d8806
    • filipe oliveira's avatar
      Speedup GEODIST with fixedpoint_d2string as an optimized version of snprintf %.4f (#11552) · 77570e39
      filipe oliveira authored
      
      
      GEODIST used snprintf("%.4f") for the reply using addReplyDoubleDistance,
      which was slow. This PR optimizes it without breaking compatibility by following
      the approach of ll2string with some changes to match the use case of distance
      and precision. I.e. we multiply it by 10000 format it as an integer, and then add
      a decimal point. This can achieve about 35% increase in the achievable ops/sec.
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      (cherry picked from commit 61c85a2b)
      77570e39
    • Yossi Gottlieb's avatar
      Improve TLS error handling. (#11563) · 60ef6d28
      Yossi Gottlieb authored
      * Remove duplicate code, propagating SSL errors into connection state.
      * Add missing error handling in synchronous IO functions.
      * Fix connection error reporting in some replication flows.
      
      (cherry picked from commit 155acef5)
      60ef6d28
    • filipe oliveira's avatar
      changing addReplySds and sdscat to addReplyStatusLength() within luaReplyToRedisReply() (#11556) · 669a8dba
      filipe oliveira authored
      profiling EVALSHA\ we see that luaReplyToRedisReply takes 8.73% out of the
      56.90% of luaCallFunction CPU cycles.
      
      Using addReplyStatusLength instead of directly composing the protocol to avoid
      sdscatprintf and addReplySds ( which imply multiple sdslen calls ).
      
      The new approach drops
      luaReplyToRedisReply CPU cycles to 3.77%
      
      (cherry picked from commit 68e87eb0)
      669a8dba
    • filipe oliveira's avatar
      Reduce eval related overhead introduced in v7.0 by evalCalcFunctionName (#11521) · 7c4f6e17
      filipe oliveira authored
      
      
      As being discussed in #10981 we see a degradation in performance
      between v6.2 and v7.0 of Redis on the EVAL command.
      
      After profiling the current unstable branch we can see that we call the
      expensive function evalCalcFunctionName twice.
      
      The current "fix" is to basically avoid calling evalCalcFunctionName and
      even dictFind(lua_scripts) twice for the same command.
      Instead we cache the current script's dictEntry (for both Eval and Functions)
      in the current client so we don't have to repeat these calls.
      The exception would be when doing an EVAL on a new script that's not yet
      in the script cache. in that case we will call evalCalcFunctionName (and even
      evalExtractShebangFlags) twice.
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      (cherry picked from commit 7dfd7b91)
      7c4f6e17
    • zhaozhao.zz's avatar
      benchmark getRedisConfig exit only when meet NOAUTH error (#11096) · fba49b10
      zhaozhao.zz authored
      redis-benchmark: when trying to get the CONFIG before benchmark,
      avoid printing any warning on most errors (e.g. NOPERM error).
      avoid aborting the benchmark on NOPERM.
      keep the warning only when we abort the benchmark on a NOAUTH error
      
      (cherry picked from commit f0005b53)
      fba49b10
    • filipe oliveira's avatar
      Simplified geoAppendIfWithinShape() and removed spurious calls do sdsdup and sdsfree (#11522) · 3d206f0f
      filipe oliveira authored
      
      
      In scenarios in which we have large datasets and the elements are not
      contained within the range we do spurious calls do sdsdup and sdsfree.
      I.e. instead of pre-creating an sds before we know if we're gonna use it
      or not, change the role of geoAppendIfWithinShape to just do geoWithinShape,
      and let the caller create the string only when needed.
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      (cherry picked from commit 376b689b)
      3d206f0f
    • DevineLiu's avatar
      [BUG] Fix announced ports not updating on local node when updated at runtime (#10745) · 81e72e8e
      DevineLiu authored
      
      
      The cluster-announce-port/cluster-announce-bus-port/cluster-announce-tls-port should take effect at runtime
      Co-authored-by: default avatarMadelyn Olson <madelyneolson@gmail.com>
      (cherry picked from commit 25ffa79b)
      81e72e8e
    • filipe oliveira's avatar
      GEOSEARCH BYBOX: Reduce wastefull computation on... · cffabb64
      filipe oliveira authored
      
      GEOSEARCH BYBOX: Reduce wastefull computation on geohashGetDistanceIfInRectangle and geohashGetDistance (#11535)
      
      Optimize geohashGetDistanceIfInRectangle when there are many misses.
      It calls 3x geohashGetDistance. The first 2 times we call them to produce intermediate results.
      This PR focus on optimizing for those 2 intermediate results.
      
      1 Reduce expensive computation on intermediate geohashGetDistance with same long
      2 Avoid expensive lon_distance calculation if lat_distance fails beforehand
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      (cherry picked from commit ae1de549)
      cffabb64
    • sundb's avatar
      Ignore -Wstringop-overread warning for SHA1Transform() on GCC 12 (#11538) · 4972f576
      sundb authored
      Fix compile warning for SHA1Transform() method under alpine with GCC 12.
      
      Warning:
      ```
      In function 'SHA1Update',
          inlined from 'SHA1Final' at sha1.c:187:9:
      sha1.c:144:13: error: 'SHA1Transform' reading 64 bytes from a region of size 0 [-Werror=stringop-overread]
        144 |             SHA1Transform(context->state, &data[i]);
            |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      sha1.c:144:13: note: referencing argument 2 of type 'const unsigned char[64]'
      sha1.c: In function 'SHA1Final':
      sha1.c:56:6: note: in a call to function 'SHA1Transform'
         56 | void SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
            |      ^~~~~~~~~~~~~
      ```
      
      This warning is a false positive because it has been determined in the loop judgment that there must be 64 chars after position `i`
      ```c
      for ( ; i + 63 < len; i += 64) {
          SHA1Transform(context->state, &data[i]);
      }
      ```
      
      Reference: https://github.com/libevent/libevent/commit/e1d7d3e40a7fd50348d849046fbfd9bf976e643c
      (cherry picked from commit fd808185)
      4972f576
    • Wen Hui's avatar
      Add explicit error log message for AOF_TRUNCATED status when server load AOF file (#11484) · d81c2a5f
      Wen Hui authored
      Now, according to the comments, if the truncated file is not the last file,
      it will be considered as a fatal error.
      And the return code will updated to AOF_FAILED, then server will exit
      without any error message to the client.
      
      Similar to other error situations, this PR add an explicit error message
      for this case and make the client know clearly what happens.
      
      (cherry picked from commit 6e9724cb)
      d81c2a5f
    • Madelyn Olson's avatar
      Explicitly send function commands to monitor (#11510) · a26ac7eb
      Madelyn Olson authored
      Both functions and eval are marked as "no-monitor", since we want to explicitly feed in the script command before the commands generated by the script. Note that we want this behavior generally, so that commands can redact arguments before being added to the monitor.
      
      (cherry picked from commit d136bf28)
      a26ac7eb
    • uriyage's avatar
      Module CLIENT_CHANGE, Fix crash on free blocked client with DB!=0 (#11500) · 7ad786db
      uriyage authored
      
      
      In moduleFireServerEvent we change the real client DB to 0 on freeClient in case the event is REDISMODULE_EVENT_CLIENT_CHANGE.
      It results in a crash if the client is blocked on a key on other than DB 0.
      
      The DB change is not necessary even for module-client, as we set its DB to 0 on either createClient or moduleReleaseTempClient.
      Co-authored-by: default avatarMadelyn Olson <34459052+madolson@users.noreply.github.com>
      Co-authored-by: default avatarBinbin <binloveplay1314@qq.com>
      (cherry picked from commit e4eb18b3)
      7ad786db
    • Oran Agra's avatar
      fixes for fork child exit and test: #11463 (#11499) · abf83bc6
      Oran Agra authored
      
      
      Fix a few issues with the recent #11463
      * use exitFromChild instead of exit
      * test should ignore defunct process since that's what we expect to
        happen for thees child processes when the parent dies.
      * fix typo
      Co-authored-by: default avatarBinbin <binloveplay1314@qq.com>
      (cherry picked from commit 4c54528f)
      abf83bc6
    • Oran Agra's avatar
      diskless master, avoid bgsave child hung when fork parent crashes (#11463) · 7c956d5c
      Oran Agra authored
      During a diskless sync, if the master main process crashes, the child would
      have hung in `write`. This fix closes the read fd on the child side, so that if the
      parent crashes, the child will get a write error and exit.
      
      This change also fixes disk-based replication, BGSAVE and AOFRW.
      In that case the child wouldn't have been hang, it would have just kept
      running until done which may be pointless.
      
      There is a certain degree of risk here. in case there's a BGSAVE child that could
      maybe succeed and the parent dies for some reason, the old code would have let
      the child keep running and maybe succeed and avoid data loss.
      On the other hand, if the parent is restarted, it would have loaded an old rdb file
      (or none), and then the child could reach the end and rename the rdb file (data
      conflicting with what the parent has), or also have a race with another BGSAVE
      child that the new parent started.
      
      Note that i removed a comment saying a write error will be ignored in the child
      and handled by the parent (this comment was very old and i don't think relevant).
      
      (cherry picked from commit ccaef5c9)
      7c956d5c
    • Moti Cohen's avatar
      Fix sentinel function that compares hostnames (if failed resolve) (#11419) · 19d01b62
      Moti Cohen authored
      Funcion sentinelAddrEqualsHostname() of sentinel makes DNS resolve
      and based on it determines if two IP addresses are equal. Now, If the
      DNS resolve command fails, the function simply returns 0, even if the
      hostnames are identical.
      
      This might become an issue in case of failover such that sentinel might
      receives from Redis instance, response to regular INFO query it sent,
      and wrongly decide that the instance is pointing to is different leader
      than the one recorded because of this function, yet hostnames are
      identical. In turn sentinel disconnects the connection between sentinel
      and valid slave which leads to -failover-abort-no-good-slave.
      See issue #11241.
      
      I managed to reproduce only part of the flow in which the function
      return wrong result and trigger +fix-slave-config.
      
      The fix is even if the function failed to resolve then compare based on
      hostnames. That is our best effort as long as the server is unavailable
      for some reason. It is fine since Redis instance cannot have multiple
      hostnames for a given setup
      
      (cherry picked from commit bd23b15a)
      19d01b62
    • sundb's avatar
      Fix crash due to to reuse iterator entry after list deletion in module (#11383) · 9fc20f4f
      sundb authored
      
      
      In the module, we will reuse the list iterator entry for RM_ListDelete, but `listTypeDelete` will only update
      `quicklistEntry->zi` but not `quicklistEntry->node`, which will result in `quicklistEntry->node` pointing to
      a freed memory address if the quicklist node is deleted.
      
      This PR sync `key->u.list.index` and `key->u.list.entry` to list iterator after `RM_ListDelete`.
      
      This PR also optimizes the release code of the original list iterator.
      Co-authored-by: default avatarViktor Söderqvist <viktor@zuiderkwast.se>
      (cherry picked from commit 6dd21355)
      9fc20f4f
    • C Charles's avatar
      MIGTATE with AUTH that contains "keys" is getting wrong key names in... · f95af778
      C Charles authored
      MIGTATE with AUTH that contains "keys" is getting wrong key names in migrateGetKeys, leads to ACL errors (#11253)
      
      When using the MIGRATE, with a destination Redis that has the user name or password set to the string "keys",
      Redis would have determine the wrong set of key names the command is gonna access.
      This lead to ACL returning wrong authentication result.
      
      Destination instance:
      ```
      127.0.0.1:6380> acl setuser default >keys
      OK
      127.0.0.1:6380> acl setuser keys on nopass ~* &* +@all
      OK
      ```
      
      Source instance:
      ```
      127.0.0.1:6379> set a 123
      OK
      127.0.0.1:6379> acl setuser cc on nopass ~a* +@all
      OK
      127.0.0.1:6379> auth cc 1
      OK
      127.0.0.1:6379> migrate 127.0.0.1 6380 "" 0 1000 auth keys keys a
      (error) NOPERM this user has no permissions to access one of the keys used as arguments
      127.0.0.1:6379> migrate 127.0.0.1 6380 "" 0 1000 auth2 keys pswd keys a
      (error) NOPERM this user has no permissions to access one of the keys used as arguments
      ```
      
      Using `acl dryrun` we know that the parameters of `auth` and `auth2` are mistaken for the `keys` option.
      ```
      127.0.0.1:6379> acl dryrun cc migrate whatever whatever "" 0 1000 auth keys keys a
      "This user has no permissions to access the 'keys' key"
      127.0.0.1:6379> acl dryrun cc migrate whatever whatever "" 0 1000 auth2 keys pswd keys a
      "This user has no permissions to access the 'pswd' key"
      ```
      
      Fix the bug by editing db.c/migrateGetKeys function, which finds the `keys` option and all the keys following.
      
      (cherry picked from commit 9ab873d9)
      f95af778
    • Oran Agra's avatar
      Improve linux overcommit check and warning (#11357) · 92ad0b5c
      Oran Agra authored
      1. show the overcommit warning when overcommit is disabled (2),
         not just when it is set to heuristic (0).
      2. improve warning text to mention the issue with jemalloc causing VM
         mapping fragmentation when set to 2.
      
      (cherry picked from commit dd60c6c8)
      92ad0b5c
    • Meir Shpilraien (Spielrein)'s avatar
      `RedisModule_ResetDataset` should not clear the functions. (#11268) · 6cf24fa4
      Meir Shpilraien (Spielrein) authored
      As mentioned on docs, `RM_ResetDataset` Performs similar operation to FLUSHALL.
      As FLUSHALL do not clean the function, `RM_ResetDataset` should not clean the functions
      as well.
      
      (cherry picked from commit d2ad01ab)
      6cf24fa4
    • Meir Shpilraien (Spielrein)'s avatar
      Avoid crash on crash report when a bad function pointer was called (#11298) · b1ede212
      Meir Shpilraien (Spielrein) authored
      If Redis crashes due to calling an invalid function pointer,
      the `backtrace` function will try to dereference this invalid pointer
      which will cause a crash inside the crash report and will kill
      the processes without having all the crash report information.
      
      Example:
      
      ```
      === REDIS BUG REPORT START: Cut & paste starting from here ===
      198672:M 19 Sep 2022 18:06:12.936 # Redis 255.255.255 crashed by signal: 11, si_code: 1
      198672:M 19 Sep 2022 18:06:12.936 # Accessing address: 0x1
      198672:M 19 Sep 2022 18:06:12.936 # Crashed running the instruction at: 0x1
      // here the processes is crashing
      ```
      
      This PR tries to fix this crash be:
      1. Identify the issue when it happened.
      2. Replace the invalid pointer with a pointer to some dummy function
         so that `backtrace` will not crash.
      
      I identification is done by comparing `eip` to `info->si_addr`, if they
      are the same we know that the crash happened on the same address it tries to
      accesses and we can conclude that it tries to call and invalid function pointer.
      
      To replace the invalid pointer we introduce a new function, `setMcontextEip`,
      which is very similar to `getMcontextEip` and it knows to set the Eip for the
      different supported OS's. After printing the trace we retrieve the old `Eip` value.
      
      (cherry picked from commit 0bf90d94)
      b1ede212
    • guybe7's avatar
      RM_CreateCommand should not set CMD_KEY_VARIABLE_FLAGS automatically (#11320) · 5b2119c6
      guybe7 authored
      The original idea behind auto-setting the default (first,last,step) spec was to use
      the most "open" flags when the user didn't provide any key-spec flags information.
      
      While the above idea is a good approach, it really makes no sense to set
      CMD_KEY_VARIABLE_FLAGS if the user didn't provide the getkeys-api flag:
      in this case there's not way to retrieve these variable flags, so what's the point?
      
      Internally in redis there was code to ignore this already, so this fix doesn't change
      redis's behavior, it only affects the output of COMMAND command.
      
      (cherry picked from commit 3330ea18)
      5b2119c6
    • Steffen Moser's avatar
      Fixing compilation by removing flock() when compiling on Solaris (#11327) · 929ab58a
      Steffen Moser authored
      SunOS/Solaris and its relatives don't support the flock() function.
      While "redis" has been excluding setting up the lock using flock() on the cluster
      configuration file when compiling under Solaris, it was still using flock() in the
      unlock call while shutting down.
      
      This pull request eliminates the flock() call also in the unlocking stage
      for Oracle Solaris and its relatives.
      
      Fix compilation regression from #10912
      
      (cherry picked from commit 6aab4cb7)
      929ab58a
    • Binbin's avatar
      Fix CLUSTER SHARDS showing empty hostname (#11297) · 79414d45
      Binbin authored
      * Fix CLUSTER SHARDS showing empty hostname
      
      In #10290, we changed clusterNode hostname from `char*`
      to `sds`, and the old `node->hostname` was changed to
      `sdslen(node->hostname)!=0`.
      
      But in `addNodeDetailsToShardReply` it is missing.
      It results in the return of an empty string hostname
      in CLUSTER SHARDS command if it unavailable.
      
      Like this (note that we listed it as optional in the doc):
      ```
       9) "hostname"
      10) ""
      ```
      
      (cherry picked from commit 1de675b3)
      79414d45
    • Shaya Potter's avatar
      Add RM_SetContextUser to support acl validation in RM_Call (and scripts) (#10966) · b8fcd322
      Shaya Potter authored
      Adds a number of user management/ACL validaiton/command execution functions to improve a
      Redis module's ability to enforce ACLs correctly and easily.
      
      * RM_SetContextUser - sets a RedisModuleUser on the context, which RM_Call will use to both
        validate ACLs (if requested and set) as well as assign to the client so that scripts executed via
        RM_Call will have proper ACL validation.
      * RM_SetModuleUserACLString - Enables one to pass an entire ACL string, not just a single OP
        and have it applied to the user
      * RM_GetModuleUserACLString - returns a stringified version of the user's ACL (same format as dump
        and list).  Contains an optimization to cache the stringified version until the underlying ACL is modified.
      * Slightly re-purpose the "C" flag to RM_Call from just being about ACL check before calling the
        command, to actually running the command with the right user, so that it also affects commands
        inside EVAL scripts. see #11231
      
      (cherry picked from commit 6e993a5d)
      b8fcd322
    • Valentino Geron's avatar
      Replica that asks for rdb only should be closed right after the rdb part (#11296) · d279ec25
      Valentino Geron authored
      The bug is that the the server keeps on sending newlines to the client.
      As a result, the receiver might not find the EOF marker since it searches
      for it only on the end of each payload it reads from the socket.
      The but only affects `CLIENT_REPL_RDBONLY`.
      This affects `redis-cli --rdb` (depending on timing)
      
      The fixed consist of two steps:
      1. The `CLIENT_REPL_RDBONLY` should be closed ASAP (we cannot
         always call to `freeClient` so we use `freeClientAsync`)
      2. Add new replication state `SLAVE_STATE_RDB_TRANSMITTED`
      
      (cherry picked from commit e53bf652)
      d279ec25
    • Ariel Shtul's avatar
      [PERF] use snprintf once in addReplyDouble (#11093) · a221fc85
      Ariel Shtul authored
      The previous implementation calls `snprintf` twice, the second time used to
      'memcpy' the output of the first, which could be a very large string.
      The new implementation reserves space for the protocol header ahead
      of the formatted double, and then prepends the string length ahead of it.
      
      Measured improvement of simple ZADD of some 25%.
      
      (cherry picked from commit 90223759)
      a221fc85
  2. 21 Sep, 2022 1 commit