Ban snapshot-creating commands and other admin commands from transactions#10015
Ban snapshot-creating commands and other admin commands from transactions#10015oranagra merged 8 commits intoredis:unstablefrom
Conversation
Others: 1. Add some missing command flags to COMMAND's output
* no need to check CMD_NO_MULTI inside EXEC * revert accidental deletion of no_mandatory_keys * use AOF for the "MULTI with FLUSHALL" instead of replication
|
@redis/core-team please approve, and state if you think this should be mentioned in the release notes as a breaking change. |
|
Change makes sense to me and should be noted as breaking despite not being documented. Should it be documented now (i.e. commands that can't be run from multi) somewhere (e.g. https://redis.io/topics/transactions)? |
yossigo
left a comment
There was a problem hiding this comment.
LGTM, and I do think this should be listed in the release notes as a breaking change.
|
I believe we should ban And some other commands I discussed in #5666. |
|
About |
|
I thought it's a valid way out of the problem, i was about to suggest it for The contract with the user is that when append only is enabled (during runtime in this case), as soon as the config command replies with OK, the data is guaranteed to be persisted. this is why redis will refuse to shutdown in the initial AOFRW is in progress. instead, i think we can just modify Regarding BGSAVE and BGAOFREWRITE, it may be slightly misleading for the user. then i think their intention might have been to actually break the transaction and start the fork (snapshot) half way. So to sum up, i think we can change this PR and add the new flag to SYNC, PSYNC, SLAVEOF, REPLICAOF, SHUTDOWN. |
|
I just wanna try our best to make it compatible with user's old behavior, because I'm not sure if some scripts are doing like that, but I'm OK if we all think a breaking change is better. |
|
i just found this test, which is apparently working, so although i think it's an invalid case, it's currently solve, so we can keep it this way. test {MULTI / EXEC with REPLICAOF} {
# This test verifies that if we demote a master to replica inside a transaction, the
# entire transaction is not propagated to the already-connected replica
set repl [attach_to_replication_stream]
r set foo bar
r multi
r set foo2 bar
r replicaof localhost 9999
r set foo3 bar
r exec
catch {r set foo4 bar} e
assert_match {READONLY*} $e
assert_replication_stream $repl {
{select *}
{set foo bar}
}
r replicaof no one
} {OK} {needs:repl cluster:skip} |
It was introduced in #9890 , and I think it's an invalid case we should remove it, WDYT @guybe7 ? |
|
ohh, i have a short memory.. seems like i asked for that test. |
|
Let's block it |
i realize i was wrong. |
|
@oranagra @soloestoy so we'll just make sure to add "transaction" to the list of cases in which CONFIG SET avoids starting a fork. sound good? |
|
we discussed this in a core-team meeting.
|
* don't block BGSAVE and BGREWRITEAOF * block PSYNC, SYNC, and SHUTDOWN * BGSAVE and BGREWRITEAOF will set the schedule flag instead of forking * CONFIG SET appendonly willl set the schedule flag instead of forking * add tests for all of the above unrealted * add test for config that fails inside MULTI * add test for FLUSHDB inside MULTI
|
@redis/core-team i made the changes we discussed, please take a quick look at the top comment and approve. |
madolson
left a comment
There was a problem hiding this comment.
Changes reflect our discussions, so LGTM.
The dbs doesn't have any keys, `rdb-key-save-delay` config has no effect that cause the rewrite to complete. It was introduced in redis#10015.
The dbs doesn't have any keys, `rdb-key-save-delay` config has no effect that cause the rewrite to complete. It was introduced in #10015.
Creating fork (or even a foreground SAVE) during a transaction breaks the atomicity of the transaction.
In addition to that, it could mess up the propagated transaction to the AOF file.
This change blocks SAVE, PSYNC, SYNC and SHUTDOWN from being executed inside MULTI-EXEC.
It does that by adding a command flag, so that modules can flag their commands with that flag too.
Besides it changes BGSAVE, BGREWRITEAOF, and CONFIG SET appendonly, to turn the
scheduled flag instead of forking righ taway.
Other changes:
protected,no-async-loading, andno_multiflags in COMMAND command