PUBLISH is not replicated from EVAL unless other commands in script increment server.dirty #873

Closed
antirez opened this Issue Jan 10, 2013 · 1 comment

Comments

Projects
None yet
1 participant
Owner

antirez commented Jan 10, 2013

PUBLISH is usually replicated using a command flag that forces replication. This way we avoid incrementing server.dirty because there is no need at all to add PUBLISH commands into the AOF.

However when called from a Lua script the flag has no effect, and the command will be replicated only if there is another command in the script incrementing server.dirty.

The quick & dirty fix would be trivial, but maybe it's better to fix this for 2.8 with a proper solution that improves the concept of server.dirty quite a bit. A faster fix will be created for 2.6 as a temporary solution.

For 2.8 what I think is that server.dirty should be not touched by commands implementations directly, instead we should have APIs to call like that:

  • propagate(flags,changes);

That allows to specify where to propagate the command (AOF, replication channel, and so forth) and the amount of changes this command represent, that is useful to trigger RDB saving.

However our call() function is called recursively by EVAL, MULTI/EXEC, and in other contexts, so this should be implemented with counters in the client structure or something like that in order to work properly.

In short: more design needed.

@antirez antirez added a commit that referenced this issue Jun 21, 2013

@antirez antirez New API to force propagation.
The old REDIS_CMD_FORCE_REPLICATION flag was removed from the
implementation of Redis, now there is a new API to force specific
executions of a command to be propagated to AOF / Replication link:

    void forceCommandPropagation(int flags);

The new API is also compatible with Lua scripting, so a script that will
execute commands that are forced to be propagated, will also be
propagated itself accordingly even if no change to data is operated.

As a side effect, this new design fixes the issue with scripts not able
to propagate PUBLISH to slaves (issue #873).
515a26b
Owner

antirez commented Jun 21, 2013

Fixed

antirez closed this Jun 21, 2013

@antirez antirez added a commit that referenced this issue Jun 26, 2013

@antirez antirez New API to force propagation.
The old REDIS_CMD_FORCE_REPLICATION flag was removed from the
implementation of Redis, now there is a new API to force specific
executions of a command to be propagated to AOF / Replication link:

    void forceCommandPropagation(int flags);

The new API is also compatible with Lua scripting, so a script that will
execute commands that are forced to be propagated, will also be
propagated itself accordingly even if no change to data is operated.

As a side effect, this new design fixes the issue with scripts not able
to propagate PUBLISH to slaves (issue #873).
8328d99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment