Skip to content

Lua Script Cannot be Parsed after upgrading to 2.6.45 #2164

Description

@robertmircea

I've upgraded StackExchange.Redis nuget package to the latest version 2.6.45 and I've noticed that my previously working Lua script is no longer accepted at startup by Stack Exchange library. The exception thrown is

System.ArgumentException: Count not parse script: [...]
-------------------------------------------------------------------------------
-- API definitions
-------------------------------------------------------------------------------
local MessageStoreAPI = {}

MessageStoreAPI.confirmPendingDelivery = function(smscMessageId, smscDeliveredAt, smscMessageState)
    local messageId = redis.call('hget', "smId:" .. smscMessageId, 'mId')
    if not messageId then
        return nil
    end
    -- delete pending delivery
    redis.call('del', "smId:" .. smscMessageId)

    local mIdK = 'm:'..messageId

    local result = redis.call('hsetnx', mIdK, 'sState', smscMessageState)
    if result == 1 then
        redis.call('hset', mIdK, 'sDlvAt', smscDeliveredAt)
        redis.call('zrem', "msg.validUntil", messageId)
        return redis.call('hget', mIdK, 'payload')
    else
        return nil
    end
end


-------------------------------------------------------------------------------
-- Function lookup
-------------------------------------------------------------------------------

-- None of the function calls accept keys
if #KEYS > 0 then error('No Keys should be provided') end

-- The first argument must be the function that we intend to call, and it must
-- exist
local command_name = assert(table.remove(ARGV, 1), 'Must provide a command as first argument')
local command      = assert(MessageStoreAPI[command_name], 'Unknown command ' .. command_name)

return command(unpack(ARGV))

   at StackExchange.Redis.ScriptParameterMapper.PrepareScript(String script) in /_/src/StackExchange.Redis/ScriptParameterMapper.cs:line 145
   at StackExchange.Redis.LuaScript.Prepare(String script) in /_/src/StackExchange.Redis/LuaScript.cs:line 92

The very same script is working when using a previous version of StackExchange.Redis. Any hint on what's going on? The exception's message is not very helpful at pointing the error.

Activity

  1. mgravell commented on Jun 18, 2022

    @mgravell
    Collaborator

    Hi; can you show the calling line of your code that leads to this? So I can out together a minimal repro. I don't recall any specific script changes, but: we can look!

  2. robertmircea commented on Jun 18, 2022

    @robertmircea
    Author
            private void Reload()
            {
                var scriptContent = File.ReadAllText(messageStoreSettings.RedisConfig.LuaScriptPath);
    
    	   //next line throws
                var prepared = LuaScript.Prepare(scriptContent);
    	    [...]
    	}
    
  3. mgravell commented on Jun 21, 2022

    @mgravell
    Collaborator

    Confirmed; this is a breaking change, and can be repro'd with just LuaScript.Prepare("return 42");. The change impacts scripts without parameters, and is here - @NickCraver is this a considered/deliberate thing? In fairness, the benefit of this API when there are no parameters seems ... nil (compared to ScriptEvaluate), but: I guess it is technically legal? I also vaguely seem to recall a brief discussion about this, but I might be misremembering.

  4. mgravell commented on Jun 21, 2022

    @mgravell
    Collaborator

    also: "count not" is weird phrasing; "count not, lest ye be counted!"

  5. added a commit that references this issue on Jun 21, 2022
    17495e9
  6. added 2 commits that reference this issue on Jun 21, 2022
    bc0c5a2
    0ebe530
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions