Skip to content

some commands' flags should be set correctly, issue #4834#4835

Merged
antirez merged 1 commit intoredis:unstablefrom
soloestoy:command-script-flag
Aug 29, 2018
Merged

some commands' flags should be set correctly, issue #4834#4835
antirez merged 1 commit intoredis:unstablefrom
soloestoy:command-script-flag

Conversation

@soloestoy
Copy link
Contributor

@soloestoy soloestoy commented Apr 10, 2018

see more details in issue #4834

@antirez
Copy link
Contributor

antirez commented Jun 8, 2018

Hello @soloestoy, thanks for the PR, certain changes make sense to me, other look a bit too strict, for instance in some instance it is good that Lua scripts can call administrative commands. I guess that in the case of TTL you wanted to add R because the master and the slave cannot return this information in a consistent way? Btw I'll can the list item per item and comment accordingly. Thanks.

@soloestoy
Copy link
Contributor Author

Hello @antirez

I guess that in the case of TTL you wanted to add R because the master and the slave cannot return this information in a consistent way?

Yes, the TTL is a problem.

for instance in some instance it is good that Lua scripts can call administrative commands

Maybe slowlog can be allowed.

But shutdown, bgsave, config and bgrewriteaof should not be allowed I think, because these commands executed in a lua script may lead to data inconsistency between AOF and memory:

  1. bgrewriteaof should not be allowed in scripts, just see the case below:

    127.0.0.1:6379> del a
    (integer) 1
    127.0.0.1:6379> config set appendonly yes
    OK
    127.0.0.1:6379> eval "redis.call('incr','a') redis.call('bgrewriteaof')" 0
    (nil)
    127.0.0.1:6379> get a
     "1"
    127.0.0.1:6379> debug loadaof
    OK
    127.0.0.1:6379> get a
    "2"
    

    We can see that after reload aof, key a has different value, that's because command incr a in lua script has already been executed and then bgrewriteaof will persist the key-value pair to AOF file, and then the whole script will be stored in AOF file too, it means that incr command has been stored twice.

  2. config should not be allowed in scripts, because config set appendonly yes may trigger AOF rewrite.

  3. bgsave should not be allowed in scripts, because it may get different reply if there are child process saving RDB/AOF or not.

  4. shutdown should not be allowed in scripts, because EXEC may be lost in AOF file if we use redis.replicate_commands(). And this will break scripts' atomicity.

@soloestoy soloestoy force-pushed the command-script-flag branch from 75ce9c0 to 3284417 Compare August 29, 2018 10:07
@antirez antirez merged commit 0e21efd into redis:unstable Aug 29, 2018
@antirez
Copy link
Contributor

antirez commented Aug 29, 2018

Thank you @soloestoy, merged.

soloestoy added a commit to soloestoy/libredis-BSD that referenced this pull request Aug 29, 2018
@soloestoy
Copy link
Contributor Author

Oops.. this PR is too old, I just wanna update it but you merged it before that @antirez , just open another PR #5296.

@antirez
Copy link
Contributor

antirez commented Aug 29, 2018

@soloestoy no problem , just merged the other one as well :-) Thanks

antirez added a commit that referenced this pull request Aug 29, 2018
Supplement to PR #4835, just take info/memory/command as random commands
@soloestoy
Copy link
Contributor Author

We have another problem about random write commands... @antirez see PR #5208.

JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Dec 17, 2018
some commands' flags should be set correctly, issue redis#4834
JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Dec 17, 2018
JackieXie168 pushed a commit to JackieXie168/redis that referenced this pull request Dec 17, 2018
Supplement to PR redis#4835, just take info/memory/command as random commands
pulllock pushed a commit to pulllock/redis that referenced this pull request Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants