Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
eb87da61
Commit
eb87da61
authored
Aug 02, 2018
by
zhaozhao.zz
Browse files
AOF: discard if we lost EXEC when loading aof
parent
39c70e72
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/aof.c
View file @
eb87da61
...
@@ -677,6 +677,7 @@ int loadAppendOnlyFile(char *filename) {
...
@@ -677,6 +677,7 @@ int loadAppendOnlyFile(char *filename) {
int old_aof_state = server.aof_state;
int old_aof_state = server.aof_state;
long loops = 0;
long loops = 0;
off_t valid_up_to = 0; /* Offset of latest well-formed command loaded. */
off_t valid_up_to = 0; /* Offset of latest well-formed command loaded. */
off_t valid_before_multi = 0; /* Offset before MULTI command loaded. */
if (fp == NULL) {
if (fp == NULL) {
serverLog(LL_WARNING,"Fatal error: can't open the append log file for reading: %s",strerror(errno));
serverLog(LL_WARNING,"Fatal error: can't open the append log file for reading: %s",strerror(errno));
...
@@ -781,9 +782,15 @@ int loadAppendOnlyFile(char *filename) {
...
@@ -781,9 +782,15 @@ int loadAppendOnlyFile(char *filename) {
exit(1);
exit(1);
}
}
if (cmd == server.multiCommand) valid_before_multi = valid_up_to;
/* Run the command in the context of a fake client */
/* Run the command in the context of a fake client */
fakeClient->cmd = cmd;
fakeClient->cmd = cmd;
cmd
->
proc
(
fakeClient
);
if (fakeClient->flags & CLIENT_MULTI && fakeClient->cmd->proc != execCommand) {
queueMultiCommand(fakeClient);
} else {
cmd->proc(fakeClient);
}
/* The fake client should not have a reply */
/* The fake client should not have a reply */
serverAssert(fakeClient->bufpos == 0 && listLength(fakeClient->reply) == 0);
serverAssert(fakeClient->bufpos == 0 && listLength(fakeClient->reply) == 0);
...
@@ -801,7 +808,11 @@ int loadAppendOnlyFile(char *filename) {
...
@@ -801,7 +808,11 @@ int loadAppendOnlyFile(char *filename) {
* If the client is in the middle of a MULTI/EXEC, handle it as it was
* If the client is in the middle of a MULTI/EXEC, handle it as it was
* a short read, even if technically the protocol is correct: we want
* a short read, even if technically the protocol is correct: we want
* to remove the unprocessed tail and continue. */
* to remove the unprocessed tail and continue. */
if
(
fakeClient
->
flags
&
CLIENT_MULTI
)
goto
uxeof
;
if (fakeClient->flags & CLIENT_MULTI) {
serverLog(LL_WARNING,"!!! Warning: we lost EXEC in the middle of transaction, discard !!!");
valid_up_to = valid_before_multi;
goto uxeof;
}
loaded_ok: /* DB loaded, cleanup and return C_OK to the caller. */
loaded_ok: /* DB loaded, cleanup and return C_OK to the caller. */
fclose(fp);
fclose(fp);
...
...
src/multi.c
View file @
eb87da61
...
@@ -158,7 +158,7 @@ void execCommand(client *c) {
...
@@ -158,7 +158,7 @@ void execCommand(client *c) {
must_propagate
=
1
;
must_propagate
=
1
;
}
}
call
(
c
,
CMD_CALL_FULL
);
call
(
c
,
server
.
loading
?
CMD_CALL_NONE
:
CMD_CALL_FULL
);
/* Commands may alter argc/argv, restore mstate. */
/* Commands may alter argc/argv, restore mstate. */
c
->
mstate
.
commands
[
j
].
argc
=
c
->
argc
;
c
->
mstate
.
commands
[
j
].
argc
=
c
->
argc
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment