1. 23 Sep, 2024 1 commit
  2. 08 Aug, 2024 1 commit
  3. 03 Aug, 2024 1 commit
  4. 25 May, 2024 1 commit
    • Yves LeBras's avatar
      redis-cli --keystats and --keystats-samples with --top and --cursor (#12826) · 6801a3ce
      Yves LeBras authored
      
      
      Added `--keystats` and `--keystats-samples <n>` commands.
      
      The new commands combines memkeys and bigkeys with additional
      distribution data.
      We often run memkeys and bigkeys one after the other. It will be
      convenient to just have one command.
      Distribution and top 10 key sizes are useful when we have multiple keys
      taking a lot of memory.
      
      Like for memkeys and bigkeys, we can use `-i <n>` and Ctrl-C to
      interrupt the scan loop. It will still show the statistics on the keys
      sampled so far.
      We can use two new optional parameters:
      - `--cursor <n>` to continue from the last cursor after an interruption
      of the scan.
      - `--top <n>` to change the number of top key sizes (10 by default).
      
      Implemented a fix for the `--memkeys-samples 0` issue in order to use
      `--keystats-samples 0`.
      
      Used hdr_histogram for the key size distribution.
      
      For key length, hdr_histogram seemed overkill and preset ranges were
      used.
      
      The memory used by keystats with hdr_histogram is around 7MB (compared
      to 3MB for memkeys or bigkeys).
      
      Execution time is somewhat equivalent to adding memkeys and bigkeys
      time. Each scan loop is having more commands (key type, key size, key
      length/cardinality).
      
      We can redirect the output to a file. In that case, no color or text
      refresh will happen.
      
      Limitation:
      - As the information printed during the loop is refreshed (moving cursor
      up), stderr and information not fitting in the terminal window (width or
      height) might create some refresh issues.
      
      Comments:
      - config.top_sizes_limit could be used globally like config.count, but
      it is passed as parameter to be consistent with config.memkeys_samples.
      - Not sure if we should move some utility functions to cli-common.c.
      
      Got some tips and help from @ofirluzon.
      
      ---------
      Co-authored-by: default avatarBinbin <binloveplay1314@qq.com>
      Co-authored-by: default avatarViktor Söderqvist <viktor.soderqvist@est.tech>
      Co-authored-by: default avatardebing.sun <debing.sun@redis.com>
      6801a3ce
  5. 10 May, 2024 1 commit
    • ClaytonNorthey92's avatar
      Add reverse history search in redis-cli (linenoise) (#12543) · 8a05f009
      ClaytonNorthey92 authored
      added reverse history search to redis-cli, use it with the following:
      
      * CTRL+R : enable search backward mode, and search next one when
      pressing CTRL+R again until reach index 0.
      ```
      127.0.0.1:6379> keys one
      127.0.0.1:6379> keys two
      (reverse-i-search):                   # press CTRL+R
      (reverse-i-search): keys two          # input `keys`
      (reverse-i-search): keys one          # press CTRL+R again
      (reverse-i-search): keys one          # press CTRL+R again, still `keys one` due to reaching index 0
      (i-search): keys two                  # press CTRL+S, enable search forward
      (i-search): keys two                  # press CTRL+S, still `keys one` due to reaching index 1
      ```
      
      * CTRL+S : enable search forward mode, and search next one when pressing
      CTRL+S again until reach index 0.
      ```
      127.0.0.1:6379> keys one
      127.0.0.1:6379> keys two
      (i-search):                       # press CTRL+S
      (i-search): keys one              # input `keys`
      (i-search): keys two              # press CTRL+S again
      (i-search): keys two              # press CTRL+R again, still `keys two` due to reaching index 0
      (reverse-i-search): keys one      # press CTRL+R, enable search backward
      (reverse-i-search): keys one      # press CTRL+S, still `keys one` due to reaching index 1
      ```
      
      * CTRL+G : disable
      ```
      127.0.0.1:6379> keys one
      127.0.0.1:6379> keys two
      (reverse-i-search):                   # press CTRL+R
      (reverse-i-search): keys two          # input `keys`
      127.0.0.1:6379>                       # press CTRL+G
      ```
      
      * CTRL+C : disable
      ```
      127.0.0.1:6379> keys one
      127.0.0.1:6379> keys two
      (reverse-i-search):                   # press CTRL+R
      (reverse-i-search): keys two          # input `keys`
      127.0.0.1:6379>                       # press CTRL+G
      ```
      
      * TAB : use the current search result and exit search mode
      ```
      127.0.0.1:6379> keys one
      127.0.0.1:6379> keys two
      (reverse-i-search):                # press CTRL+R
      (reverse-i-search): keys two       # input `keys`
      127.0.0.1:6379> keys two           # press TAB
      ```
      
      * ENTER : use the current search result and execute the command
      ```
      127.0.0.1:6379> keys one
      127.0.0.1:6379> keys two
      (reverse-i-search):                 # press CTRL+R
      (reverse-i-search): keys two        # input `keys`
      127.0.0.1:6379> keys two            # press ENTER
      (empty array)
      127.0.0.1:6379>
      ```
      
      * any arrow key will disable reverse search
      
      your result will have the search match bolded, you can press enter to
      execute the full result
      
      note: I have _only added this for multi-line mode_, as it seems to be
      forced that way when `repl` is called
      
      Closes: https://github.com/redis/redis/issues/8277
      
      
      
      ---------
      Co-authored-by: default avatarClayton Northey <clayton@knowbl.com>
      Co-authored-by: default avatarViktor Söderqvist <viktor.soderqvist@est.tech>
      Co-authored-by: default avatardebing.sun <debing.sun@redis.com>
      Co-authored-by: default avatarBjorn Svensson <bjorn.a.svensson@est.tech>
      Co-authored-by: default avatarViktor Söderqvist <viktor@zuiderkwast.se>
      8a05f009
  6. 08 Apr, 2024 1 commit
    • Yves LeBras's avatar
      redis-cli - sendReadOnly() to work with Redis Cloud (#13195) · e3550f01
      Yves LeBras authored
      When using Redis Cloud, sendReadOnly() exit with `Error: ERR unknown
      command 'READONLY'`.
      It is impacting `--memkeys`, `--bigkeys`, `--hotkeys`, and will impact
      `--keystats`.
      Added one line to ignore this error.
      
      issue introduced in #12735 (not yet released).
      e3550f01
  7. 20 Mar, 2024 1 commit
  8. 02 Mar, 2024 1 commit
    • YaacovHazan's avatar
      redis-cli fixes around help hints version filtering (#13097) · a50bbcb6
      YaacovHazan authored
      
      
      - In removeUnsupportedArgs, trying to access the next item after the
      last one and causing an out of bounds read.
      - In versionIsSupported, when the 'version' is equal to 'since', the
      return value is 0 (not supported).
      Also, change the function to return `not supported` in case they have
      different numbers of digits
      
      Both issues were found by `Non-interactive non-TTY CLI: Test
      command-line hinting - old server` under `test-sanitizer-address` (When
      changing the `src/version.h` locally to `8.0.0`)
      
      The new `MAXAGE` argument inside `client-kill` triggered the issue (new
      argument at the end of the list)
      
      ---------
      Co-authored-by: default avatarYaacovHazan <yaacov.hazan@redislabs.com>
      a50bbcb6
  9. 28 Feb, 2024 1 commit
    • LiiNen's avatar
      Fix redis-cli --count (for --scan, --bigkeys, etc) was ignored unless... · 763827c9
      LiiNen authored
      Fix redis-cli --count (for --scan, --bigkeys, etc) was ignored unless --pattern was also used (#13092)
      
      The --count option for redis-cli has been released in redis 7.2.
      https://github.com/redis/redis/pull/12042
      But I have found in code, that some logic was missing for using this
      'count' option.
      
      ```
      static redisReply *sendScan(unsigned long long *it) {
          redisReply *reply;
      
          if (config.pattern)
              reply = redisCommand(context, "SCAN %llu MATCH %b COUNT %d",
                  *it, config.pattern, sdslen(config.pattern), config.count);
          else
              reply = redisCommand(context,"SCAN %llu",*it);
      ```
      
      The intention was being able to using scan count.
      But in this case, the --count will be only applied when 'pattern' is
      declared.
      So, I had fix it simply, to be worked properly - even if --pattern
      option is not being used.
      
      I tested it simply with time() command several times, and I could see it
      works as intended with this commit.
      The examples of test results are below:
      ```
      # unstable build
      
      time(./redis-cli -a $AUTH -p $PORT -h $HOST --scan >/dev/null 2>/dev/null)
      
      real    0m1.287s
      user    0m0.011s
      sys     0m0.022s
      
      # count is not applied
      time(./redis-cli -a $AUTH -p $PORT -h $HOST --scan --count 1000 >/dev/null 2>/dev/null)
      
      real    0m1.117s
      user    0m0.011s
      sys     0m0.020s
      
      # count is applied with --pattern
      
      time(./redis-cli -a $AUTH -p $PORT -h $HOST --scan --count 1000 --pattern "hash:*" >/dev/null 2>/dev/null)
      
      real    0m0.045s
      user    0m0.002s
      sys     0m0.002s
      ```
      
      ```
      # fix-redis-cli-scan-count build
      time(./redis-cli -a $AUTH -p $PORT -h $HOST --scan >/dev/null 2>/dev/null)
      
      real    0m1.084s
      user    0m0.008s
      sys     0m0.024s
      
      # count is applied even if --pattern is not declared
      time(./redis-cli -a $AUTH -p $PORT -h $HOST --scan --count 1000 >/dev/null 2>/dev/null)
      
      real    0m0.043s
      user    0m0.000s
      sys     0m0.004s
      
      # of course this also applied
      time(./redis-cli -a $AUTH -p $PORT -h $HOST --scan --count 1000 --pattern "hash:*" >/dev/null 2>/dev/null)
      
      real    0m0.031s
      user    0m0.002s
      sys     0m0.002s
      ```
      
      
      
      Thanks a lot.
      763827c9
  10. 18 Feb, 2024 1 commit
  11. 30 Jan, 2024 1 commit
  12. 28 Dec, 2023 1 commit
    • Binbin's avatar
      Adjust redis-cli --cluster create arity from -2 to -1 (#12892) · 5b1fe925
      Binbin authored
      When arity is -2, it allows us to input two nodes, but returns:
      ```
      *** ERROR: Invalid configuration for cluster creation.
      *** Redis Cluster requires at least 3 master nodes.
      *** This is not possible with 2 nodes and 0 replicas per node.
      *** At least 3 nodes are required.
      ```
      
      When we input one node, it return:
      ```
      [ERR] Wrong number of arguments for specified --cluster sub command
      ```
      
      Strictly speaking -2 should also be rejected, because redis-cli
      requires at least three nodes. However, the error message was not
      very friendly, so decided to change it arity -1.
      
      This closes #12891.
      5b1fe925
  13. 24 Dec, 2023 1 commit
  14. 21 Dec, 2023 1 commit
    • Binbin's avatar
      Move cliVersion to cli_common and add --version support for redis-check-aof (#10856) · 23e980e7
      Binbin authored
      Let us see which version of redis this tool is part of.
      Similarly to redis-cli, redis-benchmark and redis-check-rdb
      
      redis-rdb-check and redis-aof-check are actually symlinks to redis,
      so they will directly use getVersion in server, the format became:
      ```
      {title} v={redis_version} sha={sha}:{dirty} malloc={malloc} bits={bits} build={build}
      ```
      
      Move cliVersion into cli_common, redis-cli and redis-benchmark will
      use it, and the format is not change:
      ```
      {title} {redis_version} (git:{sha})
      ```
      23e980e7
  15. 15 Dec, 2023 1 commit
    • Binbin's avatar
      Always keep an in-memory history of all commands in redis-cli (#12862) · adbb534f
      Binbin authored
      redis-cli avoids saving sensitive commands in it's history (doesn't
      persist them to the history file).
      this means that if you had a typo and you wanna re-run the command, you
      can't easily do that.
      This PR changes that to keep an in-memory history of all the redacted
      commands, and just
      not persist them to disk. This way we would be able to press the up
      arrow and
      re-try the command freely, and it'll just not survive a redis-cli
      restart.
      adbb534f
  16. 13 Dec, 2023 1 commit
    • Binbin's avatar
      Redact ACL username information and mark *-key-file-pass configs as sensitive (#12860) · 3c0fd252
      Binbin authored
      In #11489, we consider acl username to be sensitive information,
      and consider the ACL GETUSER a sensitive command and remove it
      from redis-cli historyfile.
      
      This PR redact username information in ACL GETUSER and ACL DELUSER
      from SLOWLOG, and also remove ACL DELUSER from redis-cli historyfile.
      
      This PR also mark tls-key-file-pass and tls-client-key-file-pass
      as sensitive config, will redact it from SLOWLOG and also
      remove them from redis-cli historyfile.
      3c0fd252
  17. 20 Nov, 2023 1 commit
  18. 19 Nov, 2023 1 commit
    • Hwang Si Yeon's avatar
      Add an explanation for URI with -u in redis-cli --help (#12751) · a1f91ffa
      Hwang Si Yeon authored
      Add documentation of the URI format in the `--help` output of
      `redis-cli` and `redis-benchmark`.
      
      In particular, it's good for users to know that they need to specify
      "default" as the username when authenticating without a username. Other
      details of the URI format are described too, like scheme and dbnum.
      
      It used to be possible to connect to Redis using an URL with an empty
      username, like `redis-cli -u redis://:PASSWORD@localhost:6379/0`. This
      was broken in 6.2 (#8048), and there was a discussion about it #9186.
      Now, users need to specify "default" as the username and it's better to
      document it.
      
      Refer to #12746 for more details.
      a1f91ffa
  19. 05 Nov, 2023 1 commit
    • Wen Hui's avatar
      Fix the bug that write redis sensitive command information to redis_cli historyfile (#11489) · 28b6155b
      Wen Hui authored
      Currently, we do not write the following sensitive commands into the ~/.rediscli_history file:
      
      ACL SETUSER username [rule [rule ...]]
      AUTH [username] password
      HELLO [AUTH username password] 
      MIGRATE host port <key | ""> destination-db timeout [[AUTH password | AUTH2 username password]]
      CONFIG SET masterauth master-password
      CONFIG SET masteruser username
      CONFIG SET requirepass foobared
      
      However, we still write the following sensitive commands into the ~/.rediscli_history file:
      ACL GETUSER username
      Sentinel CONFIG set sentinel-pass password
      Sentinel CONFIG set sentinel-user username
      Sentinel set mastername auth-pass password
      Sentinel set mastername auth-user username
      
      This change adds the commands of the second list to be skipped from being written to the history file.
      
      28b6155b
  20. 11 Oct, 2023 1 commit
    • Binbin's avatar
      Fix redis-cli pubsub_mode and connect minor prompt / crash issue (#12571) · 4de4fcf2
      Binbin authored
      When entering pubsub mode and using the redis-cli only
      connect command, we need to reset pubsub_mode because
      we switch to a different connection.
      
      This will affect the prompt when the connection is successful,
      and redis-cli will crash when the connect fails:
      ```
      127.0.0.1:6379> subscribe ch
      1) "subscribe"
      2) "ch"
      3) (integer) 1
      127.0.0.1:6379(subscribed mode)> connect 127.0.0.1 6380
      127.0.0.1:6380(subscribed mode)> ping
      PONG
      127.0.0.1:6380(subscribed mode)> connect a b
      Could not connect to Redis at a:0: Name or service not known
      Segmentation fault
      ```
      4de4fcf2
  21. 02 Oct, 2023 1 commit
  22. 21 Aug, 2023 1 commit
  23. 16 Aug, 2023 2 commits
  24. 20 Jul, 2023 1 commit
    • Makdon's avatar
      redis-cli: use previous hostip when not provided by redis cluster server (#12273) · 2495b90a
      Makdon authored
      
      
      When the redis server cluster running on cluster-preferred-endpoint-type unknown-endpoint mode, and receive a request that should be redirected to another redis server node, it does not reply the hostip, but a empty host like MOVED 3999 :6381.
      
      The redis-cli would try to connect to an address without a host, which cause the issue:
      ```
      127.0.0.1:7002> set bar bar
      -> Redirected to slot [5061] located at :7000
      Could not connect to Redis at :7000: No address associated with hostname
      Could not connect to Redis at :7000: No address associated with hostname
      not connected> exit
      ```
      
      In this case, the redis-cli should use the previous hostip when there's no host provided by the server.
      
      ---------
      Co-authored-by: default avatarViktor Söderqvist <viktor.soderqvist@est.tech>
      Co-authored-by: default avatarMadelyn Olson <madelynolson@gmail.com>
      2495b90a
  25. 20 Jun, 2023 1 commit
  26. 11 May, 2023 1 commit
    • kell0gg's avatar
      redis-cli - add option --count for scan (#12042) · aac8105c
      kell0gg authored
      When using scan in redis-cli, the SCAN COUNT is fixed, which means the
      full scan can take a long time if there are a lot of keys, this will let users specify
      a bigger COUNT option.
      aac8105c
  27. 03 May, 2023 1 commit
    • Madelyn Olson's avatar
      Remove prototypes with empty declarations (#12020) · 5e3be1be
      Madelyn Olson authored
      Technically declaring a prototype with an empty declaration has been deprecated since the early days of C, but we never got a warning for it. C2x will apparently be introducing a breaking change if you are using this type of declarator, so Clang 15 has started issuing a warning with -pedantic. Although not apparently a problem for any of the compiler we build on, if feels like the right thing is to properly adhere to the C standard and use (void).
      5e3be1be
  28. 18 Apr, 2023 1 commit
    • sundb's avatar
      Fix some compile warnings and errors when building with gcc-12 or clang (#12035) · 42c8c618
      sundb authored
      This PR is to fix the compilation warnings and errors generated by the latest
      complier toolchain, and to add a new runner of the latest toolchain for daily CI.
      
      ## Fix various compilation warnings and errors
      
      1) jemalloc.c
      
      COMPILER: clang-14 with FORTIFY_SOURCE
      
      WARNING:
      ```
      src/jemalloc.c:1028:7: warning: suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma? [-Wstring-concatenation]
                          "/etc/malloc.conf",
                          ^
      src/jemalloc.c:1027:3: note: place parentheses around the string literal to silence warning
                      "\"name\" of the file referenced by the symbolic link named "
                      ^
      ```
      
      REASON:  the compiler to alert developers to potential issues with string concatenation
      that may miss a comma,
      just like #9534 which misses a comma.
      
      SOLUTION: use `()` to tell the compiler that these two line strings are continuous.
      
      2) config.h
      
      COMPILER: clang-14 with FORTIFY_SOURCE
      
      WARNING:
      ```
      In file included from quicklist.c:36:
      ./config.h:319:76: warning: attribute declaration must precede definition [-Wignored-attributes]
      char *strcat(char *restrict dest, const char *restrict src) __attribute__((deprecated("please avoid use of unsafe C functions. prefer use of redis_strlcat instead")));
      ```
      
      REASON: Enabling _FORTIFY_SOURCE will cause the compiler to use `strcpy()` with check,
      it results in a deprecated attribute declaration after including <features.h>.
      
      SOLUTION: move the deprecated attribute declaration from config.h to fmacro.h before "#include <features.h>".
      
      3) networking.c
      
      COMPILER: GCC-12
      
      WARNING: 
      ```
      networking.c: In function ‘addReplyDouble.part.0’:
      networking.c:876:21: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
        876 |         dbuf[start] = '$';
            |                     ^
      networking.c:868:14: note: at offset -5 into destination object ‘dbuf’ of size 5152
        868 |         char dbuf[MAX_LONG_DOUBLE_CHARS+32];
            |              ^
      networking.c:876:21: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
        876 |         dbuf[start] = '$';
            |                     ^
      networking.c:868:14: note: at offset -6 into destination object ‘dbuf’ of size 5152
        868 |         char dbuf[MAX_LONG_DOUBLE_CHARS+32];
      ```
      
      REASON: GCC-12 predicts that digits10() may return 9 or 10 through `return 9 + (v >= 1000000000UL)`.
      
      SOLUTION: add an assert to let the compiler know the possible length;
      
      4) redis-cli.c & redis-benchmark.c
      
      COMPILER: clang-14 with FORTIFY_SOURCE
      
      WARNING:
      ```
      redis-benchmark.c:1621:2: warning: embedding a directive within macro arguments has undefined behavior [-Wembedded-directive] #ifdef USE_OPENSSL
      redis-cli.c:3015:2: warning: embedding a directive within macro arguments has undefined behavior [-Wembedded-directive] #ifdef USE_OPENSSL
      ```
      
      REASON: when _FORTIFY_SOURCE is enabled, the compiler will use the print() with
      check, which is a macro. this may result in the use of directives within the macro, which
      is undefined behavior.
      
      SOLUTION: move the directives-related code out of `print()`.
      
      5) server.c
      
      COMPILER: gcc-13 with FORTIFY_SOURCE
      
      WARNING:
      ```
      In function 'lookupCommandLogic',
          inlined from 'lookupCommandBySdsLogic' at server.c:3139:32:
      server.c:3102:66: error: '*(robj **)argv' may be used uninitialized [-Werror=maybe-uninitialized]
       3102 |     struct redisCommand *base_cmd = dictFetchValue(commands, argv[0]->ptr);
            |                                                              ~~~~^~~
      ```
      
      REASON: The compiler thinks that the `argc` returned by `sdssplitlen()` could be 0,
      resulting in an empty array of size 0 being passed to lookupCommandLogic.
      this should be a false positive, `argc` can't be 0 when strings are not NULL.
      
      SOLUTION: add an assert to let the compiler know that `argc` is positive.
      
      6) sha1.c
      
      COMPILER: gcc-12
      
      WARNING:
      ```
      In function ‘SHA1Update’,
          inlined from ‘SHA1Final’ at sha1.c:195:5:
      sha1.c:152:13: warning: ‘SHA1Transform’ reading 64 bytes from a region of size 0 [-Wstringop-overread]
        152 |             SHA1Transform(context->state, &data[i]);
            |             ^
      sha1.c:152: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])
            |      ^
      In function ‘SHA1Update’,
          inlined from ‘SHA1Final’ at sha1.c:198:9:
      sha1.c:152:13: warning: ‘SHA1Transform’ reading 64 bytes from a region of size 0 [-Wstringop-overread]
        152 |             SHA1Transform(context->state, &data[i]);
            |             ^
      sha1.c:152: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])
      ```
      
      REASON: due to the bug[https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80922], when
      enable LTO, gcc-12 will not see `diagnostic ignored "-Wstringop-overread"`, resulting in a warning.
      
      SOLUTION: temporarily set SHA1Update to noinline to avoid compiler warnings due
      to LTO being enabled until the above gcc bug is fixed.
      
      7) zmalloc.h
      
      COMPILER: GCC-12
      
      WARNING: 
      ```
      In function ‘memset’,
          inlined from ‘moduleCreateContext’ at module.c:877:5,
          inlined from ‘RM_GetDetachedThreadSafeContext’ at module.c:8410:5:
      /usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:10: warning: ‘__builtin_memset’ writing 104 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
         59 |   return __builtin___memset_chk (__dest, __ch, __len,
      ```
      
      REASON: due to the GCC-12 bug [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96503],
      GCC-12 cannot see alloc_size, which causes GCC to think that the actual size of memory
      is 0 when checking with __glibc_objsize0().
      
      SOLUTION: temporarily set malloc-related interfaces to `noinline` to avoid compiler warnings
      due to LTO being enabled until the above gcc bug is fixed.
      
      ## Other changes
      1) Fixed `ps -p [pid]`  doesn't output `<defunct>` when using procps 4.x causing `replication
        child dies when parent is killed - diskless` test to fail.
      2) Add a new fortify CI with GCC-13 and ubuntu-lunar docker image.
      42c8c618
  29. 02 Apr, 2023 1 commit
    • Wen Hui's avatar
      redis-cli - handle sensitive command redaction for variadic CONFIG SET (#11975) · a4a0eab5
      Wen Hui authored
      In the Redis 7.0 and newer version,
      config set command support multiply `<parameter> <value>` pairs, thus the previous
      sensitive command condition does not apply anymore
      
      For example:
      
      The command:
      **config set maxmemory 1GB masteruser aa** will be written to redis_cli historyfile
      
      In this PR, we update the condition for these sensitive commands
      config set masteruser <username>
      config set masterauth <master-password>
      config set requirepass foobared
      a4a0eab5
  30. 30 Mar, 2023 1 commit
    • Jason Elbaum's avatar
      Reimplement cli hints based on command arg docs (#10515) · 1f76bb17
      Jason Elbaum authored
      
      
      Now that the command argument specs are available at runtime (#9656), this PR addresses
      #8084 by implementing a complete solution for command-line hinting in `redis-cli`.
      
      It correctly handles nearly every case in Redis's complex command argument definitions, including
      `BLOCK` and `ONEOF` arguments, reordering of optional arguments, and repeated arguments
      (even when followed by mandatory arguments). It also validates numerically-typed arguments.
      It may not correctly handle all possible combinations of those, but overall it is quite robust.
      
      Arguments are only matched after the space bar is typed, so partial word matching is not
      supported - that proved to be more confusing than helpful. When the user's current input
      cannot be matched against the argument specs, hinting is disabled.
      
      Partial support has been implemented for legacy (pre-7.0) servers that do not support
      `COMMAND DOCS`, by falling back to a statically-compiled command argument table.
      On startup, if the server does not support `COMMAND DOCS`, `redis-cli` will now issue
      an `INFO SERVER` command to retrieve the server version (unless `HELLO` has already
      been sent, in which case the server version will be extracted from the reply to `HELLO`).
      The server version will be used to filter the commands and arguments in the command table,
      removing those not supported by that version of the server. However, the static table only
      includes core Redis commands, so with a legacy server hinting will not be supported for
      module commands. The auto generated help.h and the scripts that generates it are gone.
      
      Command and argument tables for the server and CLI use different structs, due primarily
      to the need to support different runtime data. In order to generate code for both, macros
      have been added to `commands.def` (previously `commands.c`) to make it possible to
      configure the code generation differently for different use cases (one linked with redis-server,
      and one with redis-cli).
      
      Also adding a basic testing framework for the command hints based on new (undocumented)
      command line options to `redis-cli`: `--test_hint 'INPUT'` prints out the command-line hint for
      a given input string, and `--test_hint_file <filename>` runs a suite of test cases for the hinting
      mechanism. The test suite is in `tests/assets/test_cli_hint_suite.txt`, and it is run from
      `tests/integration/redis-cli.tcl`.
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      Co-authored-by: default avatarViktor Söderqvist <viktor.soderqvist@est.tech>
      1f76bb17
  31. 19 Mar, 2023 1 commit
    • Viktor Söderqvist's avatar
      redis-cli: Accept commands in subscribed mode (#11873) · bbf364a4
      Viktor Söderqvist authored
      The message "Reading messages... (press Ctrl-C to quit)" is replaced by
      "Reading messages... (press Ctrl-C to quit or any key to type command)".
      
      This allows users to subscribe to more channels, to try out UNSUBSCRIBE and to
      combine pubsub with other features such as push messages from client tracking.
      
      The "Reading messages" info message is displayed in the bottom of the output in a
      distinct style and moves downward as more messages appear. When any key is pressed,
      the info message is replaced by the prompt with for entering commands.
      After entering a command and the reply is displayed, the "Reading messages" info
      messages appears again. This is added to the repl loop in redis-cli and in the
      corresponding place for non-interactive mode.
      
      An indication "(subscribed mode)" is included in the prompt when entering commands
      in subscribed mode.
      
      Also:
      * Fixes a problem that UNSUBSCRIBE hanged when used with RESP3 and push callback,
        without first entering subscribe mode. It hanged because UNSUBSCRIBE gets one or
        more push replies but no in-band reply.
      * Exit subscribed mode after RESET.
      bbf364a4
  32. 12 Mar, 2023 1 commit
  33. 03 Mar, 2023 1 commit
  34. 11 Jan, 2023 1 commit
    • Viktor Söderqvist's avatar
      Make dictEntry opaque · c84248b5
      Viktor Söderqvist authored
      Use functions for all accesses to dictEntry (except in dict.c). Dict abuses
      e.g. in defrag.c have been replaced by support functions provided by dict.
      c84248b5
  35. 04 Jan, 2023 1 commit
    • Binbin's avatar
      Make redis-cli support PSYNC command (#11647) · 4ef4c4a6
      Binbin authored
      
      
      The current redis-cli does not support the real PSYNC command, the older
      version of redis-cli can support PSYNC is because that we actually issue
      the SYNC command instead of PSYNC, so it act like SYNC (always full-sync).
      Noted that in this case we will send the SYNC first (triggered by sendSync),
      then send the PSYNC (the one in redis-cli input).
      
      Didn't bother to find which version that the order changed, we send PSYNC
      first (the one in redis-cli input), and then send the SYNC (the one triggered
      by sendSync). So even full-sync is not working anymore, and it will result
      this output (mentioned in issue #11246):
      ```
      psync dummy 0
      Entering replica output mode...  (press Ctrl-C to quit)
      SYNC with master, discarding bytes of bulk transfer until EOF marker...
      Error reading RDB payload while SYNCing
      ```
      
      This PR adds PSYNC support to redis-cli, which can handle +FULLRESYNC and
      +CONTINUE responses, and some examples will follow.
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      4ef4c4a6
  36. 29 Sep, 2022 1 commit
  37. 28 Sep, 2022 1 commit
  38. 19 Sep, 2022 1 commit
  39. 22 Aug, 2022 1 commit
    • zhenwei pi's avatar
      Introduce connAddr · bff7ecc7
      zhenwei pi authored
      
      
      Originally, connPeerToString is designed to get the address info from
      socket only(for both TCP & TLS), and the API 'connPeerToString' is
      oriented to operate a FD like:
      int connPeerToString(connection *conn, char *ip, size_t ip_len, int *port) {
          return anetFdToString(conn ? conn->fd : -1, ip, ip_len, port, FD_TO_PEER_NAME);
      }
      
      Introduce connAddr and implement .addr method for socket and TLS,
      thus the API 'connAddr' and 'connFormatAddr' become oriented to a
      connection like:
      static inline int connAddr(connection *conn, char *ip, size_t ip_len, int *port, int remote) {
          if (conn && conn->type->addr) {
              return conn->type->addr(conn, ip, ip_len, port, remote);
          }
      
          return -1;
      }
      
      Also remove 'FD_TO_PEER_NAME' & 'FD_TO_SOCK_NAME', use a boolean type
      'remote' to get local/remote address of a connection.
      
      With these changes, it's possible to support the other connection
      types which does not use socket(Ex, RDMA).
      
      Thanks to Oran for suggestions!
      Signed-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
      bff7ecc7