1. 11 6月, 2014 2 次提交
    • A
      Scripting: Fix for a #1118 regression simplified. · a3b0dbcc
      antirez 提交于
      It is more straightforward to just test for a numerical type avoiding
      Lua's automatic conversion. The code is technically more correct now,
      however Lua should automatically convert to number only if the original
      type is a string that "looks like a number", and not from other types,
      so practically speaking the fix is identical AFAIK.
      a3b0dbcc
    • M
      Scripting: Fix regression from #1118 · ba76daa4
      Matt Stancliff 提交于
      The new check-for-number behavior of Lua arguments broke
      users who use large strings of just integers.
      
      The Lua number check would convert the string to a number, but
      that breaks user data because
      Lua numbers have limited precision compared to an arbitrarily
      precise number wrapped in a string.
      
      Regression fixed and new test added.
      
      Fixes #1118 again.
      ba76daa4
  2. 05 6月, 2014 2 次提交
    • A
      Fixed dbuf variable scope in luaRedisGenericCommand(). · 42504169
      antirez 提交于
      I'm not sure if while the visibility is the inner block, the fact we
      point to 'dbuf' is a problem or not, probably the stack var isx
      guaranteed to live until the function returns. However obvious code is
      better anyway.
      42504169
    • A
      Scripting: better Lua number -> string conversion in luaRedisGenericCommand(). · 768994b6
      antirez 提交于
      The lua_to*string() family of functions use a non optimal format
      specifier when converting integers to strings. This has both the problem
      of the number being converted in exponential notation, which we don't
      use as a Redis return value when floating point numbers are involed,
      and, moreover, there is a loss of precision since the default format
      specifier is not able to represent numbers that must be represented
      exactly in the IEEE 754 number mantissa.
      
      The new code handles it as a special case using a saner conversion.
      
      This fixes issue #1118.
      768994b6
  3. 22 5月, 2014 1 次提交
    • A
      Process events with processEventsWhileBlocked() when blocked. · f4823497
      antirez 提交于
      When we are blocked and a few events a processed from time to time, it
      is smarter to call the event handler a few times in order to handle the
      accept, read, write, close cycle of a client in a single pass, otherwise
      there is too much latency added for clients to receive a reply while the
      server is busy in some way (for example during the DB loading).
      f4823497
  4. 20 5月, 2014 2 次提交
    • M
      Fix LUA_OBJCACHE segfault. · d491a479
      michael-grunder 提交于
      When scanning the argument list inside of a redis.call() invocation
      for pre-cached values, there was no check being done that the
      argument we were on was in fact within the bounds of the cache size.
      
      So if a redis.call() command was ever executed with more than 32
      arguments (current cache size #define setting) redis-server could
      segfault.
      d491a479
    • A
      Remove trailing spaces from scripting.c · d575f7a1
      antirez 提交于
      d575f7a1
  5. 15 5月, 2014 1 次提交
  6. 07 5月, 2014 8 次提交
  7. 13 2月, 2014 1 次提交
    • A
      Fix script cache bug in the scripting engine. · 9b73a274
      antirez 提交于
      This commit fixes a serious Lua scripting replication issue, described
      by Github issue #1549. The root cause of the problem is that scripts
      were put inside the script cache, assuming that slaves and AOF already
      contained it, even if the scripts sometimes produced no changes in the
      data set, and were not actaully propagated to AOF/slaves.
      
      Example:
      
          eval "if tonumber(KEYS[1]) > 0 then redis.call('incr', 'x') end" 1 0
      
      Then:
      
          evalsha <sha1 step 1 script> 1 0
      
      At this step sha1 of the script is added to the replication script cache
      (the script is marked as known to the slaves) and EVALSHA command is
      transformed to EVAL. However it is not dirty (there is no changes to db),
      so it is not propagated to the slaves. Then the script is called again:
      
          evalsha <sha1 step 1 script> 1 1
      
      At this step master checks that the script already exists in the
      replication script cache and doesn't transform it to EVAL command. It is
      dirty and propagated to the slaves, but they fail to evaluate the script
      as they don't have it in the script cache.
      
      The fix is trivial and just uses the new API to force the propagation of
      the executed command regardless of the dirty state of the data set.
      
      Thank you to @minus-infinity on Github for finding the issue,
      understanding the root cause, and fixing it.
      9b73a274
  8. 03 2月, 2014 1 次提交
  9. 05 12月, 2013 1 次提交
  10. 29 8月, 2013 1 次提交
    • A
      Fixed critical memory leak from EVAL. · 752b1fca
      antirez 提交于
      Multiple missing calls to lua_pop prevented the error handler function
      pushed on the stack for lua_pcall() to be popped before returning,
      causing a memory leak in almost all the code paths of EVAL (both
      successful calls and calls returning errors).
      
      This caused two issues: Lua leaking memory (and this was very visible
      from INFO memory output, as the 'used_memory_lua' field reported an
      always increasing amount of memory used), and as a result slower and
      slower GC cycles resulting in all the CPU being used.
      
      Thanks to Tanguy Le Barzic for noticing something was wrong with his 2.8
      slave, and for creating a testing EC2 environment where I was able to
      investigate the issue.
      752b1fca
  11. 26 6月, 2013 6 次提交
  12. 20 6月, 2013 1 次提交
  13. 19 6月, 2013 3 次提交
  14. 19 1月, 2013 1 次提交
    • G
      Fixed many typos. · 1caf0939
      guiquanz 提交于
      Conflicts fixed, mainly because 2.8 has no cluster support / files:
      	00-RELEASENOTES
      	src/cluster.c
      	src/crc16.c
      	src/redis-trib.rb
      	src/redis.h
      1caf0939
  15. 10 1月, 2013 1 次提交
    • A
      Multiple fixes for EVAL (issue #872). · 414e0665
      antirez 提交于
      1) The event handler was no restored after a timeout condition if the
         command was eventually executed with success.
      2) The command was not converted to EVAL in case of errors in the middle
         of the execution.
      3) Terrible duplication of code without any apparent reason.
      414e0665
  16. 22 11月, 2012 1 次提交
    • A
      EVALSHA is now case insensitive. · d0570c96
      antirez 提交于
      EVALSHA used to crash if the SHA1 was not lowercase (Issue #783).
      Fixed using a case insensitive dictionary type for the sha -> script
      map used for replication of scripts.
      d0570c96
  17. 09 11月, 2012 1 次提交
  18. 22 10月, 2012 1 次提交
    • A
      Differentiate SCRIPT KILL error replies. · ab551808
      antirez 提交于
      When calling SCRIPT KILL currently you can get two errors:
      
      * No script in timeout (busy) state.
      * The script already performed a write.
      
      It is useful to be able to distinguish the two errors, but right now both
      start with "ERR" prefix, so string matching (that is fragile) must be used.
      
      This commit introduces two different prefixes.
      
      -NOTBUSY and -UNKILLABLE respectively to reply with an error when no
      script is busy at the moment, and when the script already executed a
      write operation and can not be killed.
      ab551808
  19. 01 10月, 2012 1 次提交
  20. 28 9月, 2012 2 次提交
    • A
      Scripting: add helper functions redis.error_reply() and redis.status_reply(). · f1466e11
      antirez 提交于
      A previous commit introduced Redis.NIL. This commit adds similar helper
      functions to return tables with a single field set to the specified
      string so that instead of using 'return {err="My Error"}' it is possible
      to use a more idiomatic form:
      
          return redis.error_reply("My Error")
          return redis.status_reply("OK")
      f1466e11
    • A
      Scripting: redis.NIL to return nil bulk replies. · e061d797
      antirez 提交于
      Lua arrays can't contain nil elements (see
      http://www.lua.org/pil/19.1.html for more information), so Lua scripts
      were not able to return a multi-bulk reply containing nil bulk
      elements inside.
      
      This commit introduces a special conversion: a table with just
      a "nilbulk" field set to a boolean value is converted by Redis as a nil
      bulk reply, but at the same time for Lua this type is not a "nil" so can
      be used inside Lua arrays.
      
      This type is also assigned to redis.NIL, so the following two forms
      are equivalent and will be able to return a nil bulk reply as second
      element of a three elements array:
      
          EVAL "return {1,redis.NIL,3}" 0
          EVAL "return {1,{nilbulk=true},3}" 0
      
      The result in redis-cli will be:
      
          1) (integer) 1
          2) (nil)
          3) (integer) 3
      e061d797
  21. 05 9月, 2012 1 次提交
    • A
      Scripting: Force SORT BY constant determinism inside SORT itself. · 5ddee9b7
      antirez 提交于
      SORT is able to return (faster than when ordering) unordered output if
      the "BY" clause is used with a constant value. However we try to play
      well with scripting requirements of determinism providing always sorted
      outputs when SORT (and other similar commands) are called by Lua
      scripts.
      
      However we used the general mechanism in place in scripting in order to
      reorder SORT output, that is, if the command has the "S" flag set, the
      Lua scripting engine will take an additional step when converting a
      multi bulk reply to Lua value, calling a Lua sorting function.
      
      This is suboptimal as we can do it faster inside SORT itself.
      This is also broken as issue #545 shows us: basically when SORT is used
      with a constant BY, and additionally also GET is used, the Lua scripting
      engine was trying to order the output as a flat array, while it was
      actually a list of key-value pairs.
      
      What we do know is to recognized if the caller of SORT is the Lua client
      (since we can check this using the REDIS_LUA_CLIENT flag). If so, and if
      a "don't sort" condition is triggered by the BY option with a constant
      string, we force the lexicographical sorting.
      
      This commit fixes this bug and improves the performance, and at the same
      time simplifies the implementation. This does not mean I'm smart today,
      it means I was stupid when I committed the original implementation ;)
      5ddee9b7
  22. 31 8月, 2012 1 次提交
    • A
      Scripting: Reset Lua fake client reply_bytes after command execution. · 42a239b8
      antirez 提交于
      Lua scripting uses a fake client in order to run commands in the context
      of a client, accumulate the reply, and convert it into a Lua object
      to return to the caller. This client is reused again and again, and is
      referenced by the server.lua_client globally accessible pointer.
      
      However after every call to redis.call() or redis.pcall(), that is
      handled by the luaRedisGenericCommand() function, the reply_bytes field
      of the client was not set back to zero. This filed is used to estimate
      the amount of memory currently used in the reply. Because of the lack of
      reset, script after script executed, this value used to get bigger and
      bigger, and in the end on 32 bit systems it triggered the following
      assert:
      
          redisAssert(c->reply_bytes < ULONG_MAX-(1024*64));
      
      On 64 bit systems this does not happen because it takes too much time to
      reach values near to 2^64 for users to see the practical effect of the
      bug.
      
      Now in the cleanup stage of luaRedisGenericCommand() we reset the
      reply_bytes counter to zero, avoiding the issue. It is not practical to
      add a test for this bug, but the fix was manually tested using a
      debugger.
      
      This commit fixes issue #656.
      42a239b8