1. 11 Apr, 2022 2 commits
    • zhaozhao.zz's avatar
      Durability enhancement for appendfsync=always policy (#9678) · 1a7765cb
      zhaozhao.zz authored
      Durability of database is a big and old topic, in this regard Redis use AOF to
      support it, and `appendfsync=alwasys` policy is the most strict level, guarantee
      all data is both written and synced on disk before reply success to client.
      
      But there are some cases have been overlooked, and could lead to durability broken.
      
      1. The most clear one is about threaded-io mode
         we should also set client's write handler with `ae_barrier` in
         `handleClientsWithPendingWritesUsingThreads`, or the write handler would be
         called after read handler in the next event loop, it means the write command result
         could be replied to client before flush to AOF.
      2. About blocked client (mostly by module)
         in `beforeSleep()`, `handleClientsBlockedOnKeys()` should be called before
         `flushAppendOnlyFile()`, in case the unblocked clients modify data without persistence
         but send reply.
      3. When handling `ProcessingEventsWhileBlocked`
         normally it takes place when lua/function/module timeout, and we give a chance to users
         to kill the slow operation, but we should call `flushAppendOnlyFile()` before
         `handleClientsWithPendingWrites()`, in case the other clients in the last event loop get
         acknowledge before data persistence.
         for a instance:
         ```
         in the same event loop
         client A executes set foo bar
         client B executes eval "for var=1,10000000,1 do end" 0
         ```
         after the script timeout, client A will get `OK` but lose data after restart (kill redis when
         timeout) if we don't flush the write command to AOF.
      4. A more complex case about `ProcessingEventsWhileBlocked`
         it is lua timeout in transaction, for example
         `MULTI; set foo bar; eval "for var=1,10000000,1 do end" 0; EXEC`, then client will get set
         command's result before the whole transaction done, that breaks atomicity too.
         fortunately, it's already fixed by #5428 (although it's not the original purpose just a side
         effect : )), but module timeout should be fixed too.
      
      case 1, 2, 3 are fixed in this commit, the module issue in case 4 needs a followup PR.
      1a7765cb
    • Evan's avatar
      modules: add RedisModuleKey* return type to RM_OpenKey (#3719) · 574ed6b0
      Evan authored
      Change `RM_OpenKey` to return `RedisModuleKey*` instead of `void*`.
      Which is the input type of other APIs that take the value from RM_OpenKey.
      574ed6b0
  2. 10 Apr, 2022 5 commits
  3. 07 Apr, 2022 2 commits
    • chenyang8094's avatar
      Fix auto-aof-rewrite-percentage based AOFRW trigger after restart (#10550) · 625bdaf3
      chenyang8094 authored
      
      
      The `auto-aof-rewrite-percentage` config defines at what growth percentage
      an automatic AOF rewrite is triggered.
      This normally works OK since the size of the AOF file at the end of a rewrite
      is stored in `server.aof_rewrite_base_size`.
      However, on startup, redis used to store the entire size of the AOF file into that
      variable, resulting in a wrong automatic AOF rewrite trigger (could have been
      triggered much later than desired).
      This issue would only affect the first AOFRW after startup, after that future AOFRW
      would have been triggered correctly.
      This bug existed in all previous versions of Redis.
      
      This PR unifies the meaning of `server.aof_rewrite_base_size`, which only represents
      the size of BASE AOF.
      Note that after an AOFRW this size includes the size of the incremental file (all the
      commands that executed during rewrite), so that auto-aof-rewrite-percentage is the
      ratio from the size of the AOF after rewrite.
      However, on startup, it is complicated to know that size, and we compromised on
      taking just the size of the base file, this means that the first rewrite after startup can
      happen a little bit too soon.
      Co-authored-by: default avatarOran Agra <oran@redislabs.com>
      Co-authored-by: default avataryoav-steinberg <yoav@redislabs.com>
      625bdaf3
    • Oran Agra's avatar
      Fix RM_Yield bug (#10548) · 451531f1
      Oran Agra authored
      The bug was when using REDISMODULE_YIELD_FLAG_CLIENTS.
      in that case we would have only set the CLIENTS type flag in
      server.busy_module_yield_flags and then clear that flag when exiting
      RM_Yield, so we would never call unblockPostponedClients when the
      context is destroyed.
      
      This didn't really have any actual implication, which is why the tests
      couldn't (and still can't) find that since the bug only happens when
      using CLIENT, but in this case we won't have any clients to un-postpone
      i.e. clients will get rejected with BUSY error, rather than being
      postponed.
      
      Unrelated:
      * Adding tests for nested contexts, just in case.
      * Avoid nested RM_Yield calls
      451531f1
  4. 06 Apr, 2022 1 commit
    • Itamar Haber's avatar
      Fixes commands' syntices (#10534) · 3e09a8c0
      Itamar Haber authored
      Fixes in command argument in json files
      * Fixes BITFIELD's syntax ("sub-commands" can be repeated, and OVERFLOW is only valid for SET and INCR)
      * Improves readability of SET (reordered)
      * Fixes GEOSEARCH and GEOSEARCH_RO syntices (use `oneof` for mutually exclusive group instead of `optional`)
      * Fixes MIGRATE syntax (use `oneof` for mutually exclusive group instead of `optional`)
      * Fixes MODULE LOADEX syntax (the `CONFIG` token should be repeated too when using multiple configs)
      
      other:
      * make generate-command-help.rb accept a path to commands.json, or read it from stdin (e.g. `generate-commands-json.py | generate-command-help.rb -`)
      3e09a8c0
  5. 05 Apr, 2022 9 commits
    • Lu JJ's avatar
      Fix the bug that caused hash encoding errors when using hincrbyfloat or hincrby commands (#10479) · f110de4b
      Lu JJ authored
      Fixed a bug that used the `hincrbyfloat` or `hincrby` commands to make the field or value exceed the
      `hash_max_listpack_value` but did not change the object encoding of the hash structure.
      
      Add a length check for field and value, check the length of value first, if the length of value does not
      exceed `hash_max_listpack_value` then check the length of field.
      
      If the length of field or value is too long, it will reduce the efficiency of listpack, and the object encoding
      will become hashtable after AOF restart, so this is also to keep the same before and after AOF restart.
      f110de4b
    • judeng's avatar
      8a7049d3
    • Moti Cohen's avatar
      Stabilize Sentinel tests - refine failover-timeout & tilt-period (#10518) · e342bedc
      Moti Cohen authored
      Sentinel once in a while experience Sentinel TILT period or leader election 
      failure cycle. The problem is that those default timeout are too big and once 
      it happens, it breaks our tests.  Suggesting:
      - Reducing failover-timeout from 20 to 10sec (actually it is multiplied by 2 
        and reach 40sec of timeout) 
      - Modify tilt-period from default of 30sec to 5sec. When TILT period happens 
        it might lead to failover in our tests, and might cause also to failover cycle
        cycle failure.
      
      Sentinel tests should `wait_for_condition` up to 50seconds, where needed, 
      to be stable in case having single TILT period or failover failure cycle.
      
      In addition relax timing configuration for "manual failover" Sentinel test 
      (was modified several months ago as part of an effort to reduce tests runtime)
      e342bedc
    • Oran Agra's avatar
      acfb4f7a
    • Madelyn Olson's avatar
      Update json command files so they only include syntax related information (#10398) · 4ffcec29
      Madelyn Olson authored
      The command json documents should just include information about the "arguments" and the "outputs".
      I removed all of the 'functional wording' so it's clear.
      4ffcec29
    • Meir Shpilraien (Spielrein)'s avatar
      Functions: Move library meta data to be part of the library payload. (#10500) · ae020e3d
      Meir Shpilraien (Spielrein) authored
      ## Move library meta data to be part of the library payload.
      
      Following the discussion on https://github.com/redis/redis/issues/10429 and the intention to add (in the future) library versioning support, we believe that the entire library metadata (like name and engine) should be part of the library payload and not provided by the `FUNCTION LOAD` command. The reasoning behind this is that the programmer who developed the library should be the one who set those values (name, engine, and in the future also version). **It is not the responsibility of the admin who load the library into the database.**
      
      The PR moves all the library metadata (engine and function name) to be part of the library payload. The metadata needs to be provided on the first line of the payload using the shebang format (`#!<engine> name=<name>`), example:
      
      ```lua
      #!lua name=test
      redis.register_function('foo', function() return 1 end)
      ```
      
      The above script will run on the Lua engine and will create a library called `test`.
      
      ## API Changes (compare to 7.0 rc2)
      
      * `FUNCTION LOAD` command was change and now it simply gets the library payload and extract the engine and name from the payload. In addition, the command will now return the function name which can later be used on `FUNCTION DELETE` and `FUNCTION LIST`.
      * The description field was completely removed from`FUNCTION LOAD`, and `FUNCTION LIST`
      
      
      ## Breaking Changes (compare to 7.0 rc2)
      
      * Library description was removed (we can re-add it in the future either as part of the shebang line or an additional line).
      * Loading an AOF file that was generated by either 7.0 rc1 or 7.0 rc2 will fail because the old command syntax is invalid.
      
      ## Notes
      
      * Loading an RDB file that was generated by rc1 / rc2 **is** supported, Redis will automatically add the shebang to the libraries payloads (we can probably delete that code after 7.0.3 or so since there's no need to keep supporting upgrades from an RC build).
      ae020e3d
    • bugwz's avatar
      Cluster node name sanity check (#10391) · 2db0d898
      bugwz authored
      
      
      * Limit cluster node id length for CLUSTER commands loading
      * Cluster node name sanity check for length and values
      Co-authored-by: default avatarMadelyn Olson <madelyneolson@gmail.com>
      2db0d898
    • judeng's avatar
      delete obsolete REDISMODULE_EXPERIMENTAL_API define in module demos (#10527) · 9578b67e
      judeng authored
      This macro was recently removed from redismodule.h, so no longer needed.
      9578b67e
    • Binbin's avatar
      Remove outdated utils/hashtable/rehashing.c (#10526) · a95ae56b
      Binbin authored
      It is really outdated and i guessing no one will use it now. 
      Remove the corresponding utils/hashtable directory.
      closes #10235
      a95ae56b
  6. 04 Apr, 2022 4 commits
    • chenyang8094's avatar
      Fix null pointer subtraction warning (#10498) · cb625844
      chenyang8094 authored
      The warning:
      ```
      pqsort.c:106:7: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
      loop:   SWAPINIT(a, es);
              ^~~~~~~~~~~~~~~
      pqsort.c:65:47: note: expanded from macro 'SWAPINIT'
      #define SWAPINIT(a, es) swaptype = ((char *)a - (char *)NULL) % sizeof(long) || \
      ```
      Clang version:
      ```
      Apple clang version 13.1.6 (clang-1316.0.21.2)
      Target: x86_64-apple-darwin21.3.0
      Thread model: posix
      InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
      ```
      cb625844
    • Bofang Liu's avatar
      Fix mistake / outdated doc comment (#10521) · 8500ca4a
      Bofang Liu authored
      Unlike original reference code, Redis uses 64bit variable, so half the bits make it 32bit, not 16
      8500ca4a
    • Meir Shpilraien (Spielrein)'s avatar
      Fix #10508, on error, pop function and error handler from Lua stack. (#10519) · 047b6093
      Meir Shpilraien (Spielrein) authored
      If, for some reason, Redis decides not to execute the script, we need
      to pop the function and error handler from Lua stack. Otherwise, eventually
      the Lua stack will explode.
      
      Relevant only for 7.0-rc1 and 7.0-rc2.
      047b6093
    • judeng's avatar
      fix typos in aof.c (#10513) · 6cdaa277
      judeng authored
      
      
      function aofRewriteLimited in aof.c, deley->delay and NAX->MAX
      Co-authored-by: default avatarjudeng <judeng@didiglobal.com>
      6cdaa277
  7. 03 Apr, 2022 1 commit
  8. 02 Apr, 2022 1 commit
    • Viktor Söderqvist's avatar
      Turn into replica on SETSLOT (#10489) · b53c7f2c
      Viktor Söderqvist authored
      * Fix race condition where node loses its last slot and turns into replica
      
      When a node has lost its last slot and finds out from the SETSLOT command
      before the cluster bus PONG from the new owner arrives. In this case, the
      node didn't turn itself into a replica of the new slot owner.
      
      This commit adds the same logic to the SETSLOT command as already exists
      for the cluster bus PONG processing.
      
      * Revert "Fix new / failing cluster slot migration test (#10482)"
      
      This reverts commit 0b21ef8d.
      
      In this test, the old slot owner finds out that it has lost its last
      slot in a nondeterministic way. Either the cluster bus PONG from the
      new slot owner and sometimes in a SETSLOT command from redis-cli. In
      both cases, the result should be the same and the old owner should
      turn itself into a replica of the new slot owner.
      b53c7f2c
  9. 31 Mar, 2022 3 commits
    • sundb's avatar
      Fix failing moduleconfigs tests and memory leak (#10501) · b8eb2a73
      sundb authored
      Fix global `strval` not reset to NULL after being freed, causing a crash on alpine
      (most likely because the dynamic library loader doesn't init globals on reload)
      By the way, fix the memory leak of using `RedisModule_Free` to free `RedisModuleString`,
      and add a corresponding test.
      b8eb2a73
    • Madelyn Olson's avatar
      Prevent replica failover during manual takeover test (#10499) · e81bd15e
      Madelyn Olson authored
      During 11-manual-takeover.tcl, if the killing of the instances happens
      too slowly, one of the replicas might be able to promote itself.
      I'm not sure why it was slow, but it was observed taking 6 seconds
      which is enough time to do an election.
      I was able to verify the error locally by adding a small delay (1 second)
      during ASAN CI. A fix is just to disable automated failover until all the
      nodes are confirmed dead.
      e81bd15e
    • Binbin's avatar
      Fix cluster slot migration test (#10495) · a3075ca4
      Binbin authored
      Fix three timing issues in the test
      a3075ca4
  10. 30 Mar, 2022 6 commits
    • Ozan Tezcan's avatar
      Use exit code 1 on error in redis-cli (#10468) · 7da1cc3e
      Ozan Tezcan authored
      On error, redis-cli was returning `REDIS_ERR` on some cases by mistake. `REDIS_ERR` is `-1` which becomes `255` as exit code. This commit changes it and returns `1` on errors to be consistent.
      7da1cc3e
    • Binbin's avatar
      Move restart_killed_instances and verify_sentinel_auto_discovery to utils (#10497) · 6075f506
      Binbin authored
      Create a utils.tcl in sentinel/tests/includes, and move two procs to it.
      Allow sentinel test 08-hostname-conf run on its own.
      6075f506
    • dependabot[bot]'s avatar
      Bump actions/checkout from 2 to 3 (#10390) · 4e55d557
      dependabot[bot] authored
      Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
      - [Release notes](https://github.com/actions/checkout/releases)
      - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
      - [Commits](https://github.com/actions/checkout/compare/v2...v3
      
      )
      
      ---
      updated-dependencies:
      - dependency-name: actions/checkout
        dependency-type: direct:production
        update-type: version-update:semver-major
      ...
      Signed-off-by: default avatardependabot[bot] <support@github.com>
      Co-authored-by: default avatardependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
      4e55d557
    • dependabot[bot]'s avatar
      Bump actions/cache from 2 to 3 (#10463) · 8df37363
      dependabot[bot] authored
      Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3.
      - [Release notes](https://github.com/actions/cache/releases)
      - [Commits](https://github.com/actions/cache/compare/v2...v3
      
      )
      
      ---
      updated-dependencies:
      - dependency-name: actions/cache
        dependency-type: direct:production
        update-type: version-update:semver-major
      ...
      Signed-off-by: default avatardependabot[bot] <support@github.com>
      Co-authored-by: default avatardependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
      8df37363
    • Nick Chun's avatar
      Module Configurations (#10285) · bda9d74d
      Nick Chun authored
      This feature adds the ability to add four different types (Bool, Numeric,
      String, Enum) of configurations to a module to be accessed via the redis
      config file, and the CONFIG command.
      
      **Configuration Names**:
      
      We impose a restriction that a module configuration always starts with the
      module name and contains a '.' followed by the config name. If a module passes
      "config1" as the name to a register function, it will be registered as MODULENAME.config1.
      
      **Configuration Persistence**:
      
      Module Configurations exist only as long as a module is loaded. If a module is
      unloaded, the configurations are removed.
      There is now also a minimal core API for removal of standardConfig objects
      from configs by name.
      
      **Get and Set Callbacks**:
      
      Storage of config values is owned by the module that registers them, and provides
      callbacks for Redis to access and manipulate the values.
      This is exposed through a GET and SET callback.
      
      The get callback returns a typed value of ...
      bda9d74d
    • Binbin's avatar
      command json files cleanups (#10473) · e2fa6aa1
      Binbin authored
      This PR do some command json files cleanups:
      
      1. Add COMMAND TIPS to some commands
      - command-docs: add `NONDETERMINISTIC_OUTPUT_ORDER`
      - command-info: add `NONDETERMINISTIC_OUTPUT_ORDER`
      - command-list: add `NONDETERMINISTIC_OUTPUT_ORDER`
      - command: change `NONDETERMINISTIC_OUTPUT` to `NONDETERMINISTIC_OUTPUT_ORDER`
      - function-list: add `NONDETERMINISTIC_OUTPUT_ORDER`
      - latency-doctor: add `NONDETERMINISTIC_OUTPUT`, `REQUEST_POLICY:ALL_NODES` and `RESPONSE_POLICY:SPECIAL`
      - latency-graph: add `NONDETERMINISTIC_OUTPUT`, `REQUEST_POLICY:ALL_NODES` and `RESPONSE_POLICY:SPECIAL`
      - memory-doctor: add `REQUEST_POLICY:ALL_SHARDS` and `RESPONSE_POLICY:SPECIAL`
      - memory-malloc-stats: add `REQUEST_POLICY:ALL_SHARDS` and `RESPONSE_POLICY:SPECIAL`
      - memory-purge: add `REQUEST_POLICY:ALL_SHARDS` and `RESPONSE_POLICY:ALL_SUCCEEDED`
      - module-list: add `NONDETERMINISTIC_OUTPUT_ORDER`
      - msetnx: add `REQUEST_POLICY:MULTI_SHARD` and `RESPONSE_POLICY:AGG_MIN`
      - object-refcount: add `NONDETERMINISTIC_OUTPUT`
      3. Only (mostly) indentation and formatting changes:
      - cluster-shards
      - latency-history
      - pubsub-shardchannels
      - pubsub-shardnumsub
      - spublish
      - ssubscribe
      - sunsubscribe
      4. add doc_flags (DEPRECATED) to cluster-slots,  replaced_by `CLUSTER SHARDS` in 7.0
      5. command-getkeysandflags: a better summary (the old one is copy from command-getkeys)
      6. adjustment of command parameter types
      - `port` is integer, not string (`MIGRATE`, `REPLICAOF`, `SLAVEOF`)
      - `replicationid` is string, not integer (`PSYNC`)
      - `pattern` is pattern, not string (`PUBSUB CHANNELS`, `SENTINEL RESET`, `SORT`, `SORT_RO`)
      e2fa6aa1
  11. 29 Mar, 2022 4 commits
    • Oran Agra's avatar
      fix daily.yaml skip filters (#10490) · 16d206ee
      Oran Agra authored
      * missing parenthesis meant that the ubuntu and centos jobs were not
        skipped
      * the recently divided freebsd, macos, and valgrind jobs, which are now
        split into distict jobs for redis, modules, sentinel, cluster. were
        all executed, producing a build, but not running anything.
        now they're filtered at the job level
      * iothreads was missing from the skip list defaults, so was not skipped
      16d206ee
    • Viktor Söderqvist's avatar
      redis-cli: Do DNS lookup before sending CLUSTER MEET (#10436) · 35bb0212
      Viktor Söderqvist authored
      Affects `--cluster create` and `--cluster add-node`.
      35bb0212
    • zhaozhao.zz's avatar
      show cluster.links in MEMORY STATS (#10302) · 001e1925
      zhaozhao.zz authored
      001e1925
    • Oran Agra's avatar
      improve malloc efficiency for cluster slots_info_pairs (#10488) · 3b1e65a3
      Oran Agra authored
      This commit improve malloc efficiency of the slots_info_pairs mechanism in cluster.c
      by changing adlist into an array being realloced with greedy growth mechanism
      
      Recently the cluster tests are consistently failing when executed with ASAN in the CI.
      I tried to track down the commit that started it, and it appears to be #10293.
      Looking at the commit, i realize it didn't affect this test / flow, other than the
      replacement of the slots_info_pairs from sds to list.
      
      I concluded that what could be happening is that the slot range is very fragmented,
      and that results in many allocations.
      with sds, it results in one allocation and also, we have a greedy growth mechanism,
      but with adlist, we just have many many small allocations.
      this probably causes stress on ASAN, and causes it to be slow at termination.
      3b1e65a3
  12. 28 Mar, 2022 2 commits
    • Oran Agra's avatar
      introduce MAX_D2STRING_CHARS instead of 128 const (#10487) · 14b19886
      Oran Agra authored
      There are a few places that use a hard coded const of 128 to allocate a buffer for d2string.
      Replace these with a clear macro.
      Note that In theory, converting double into string could take as much as nearly 400 chars,
      but since d2string uses `%g` and not `%f`, it won't pass some 40 chars.
      
      unrelated:
      restore some changes to auto generated commands.c that got accidentally reverted in #10293
      14b19886
    • Binbin's avatar
      Make redis-cli --cluster help output to stdout (#10485) · 3f28d7d7
      Binbin authored
      redis-cli --cluster help currently outputs the help on stderr.
      This is similar to #9124
      3f28d7d7