Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue993 FT.DEL redismodule_replicate #1000

Merged
merged 12 commits into from Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/module.c
Expand Up @@ -472,7 +472,7 @@ GEN_CONCURRENT_WRAPPER(CursorCommand, argc >= 4, AggregateCommand_ExecCursor,
GEN_CONCURRENT_WRAPPER(AggregateCommand, argc >= 3, AggregateCommand_ExecAggregate,
CONCURRENT_POOL_SEARCH);

/* FT.DEL {index} {doc_id}
/* FT.DEL {index} {doc_id} [DD]
* Delete a document from the index. Returns 1 if the document was in the index, or 0 if not.
*
* **NOTE**: This does not actually delete the document from the index, just marks it as deleted
Expand Down Expand Up @@ -525,7 +525,11 @@ int DeleteCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
GCContext_OnDelete(sp->gc);
}
}
RedisModule_Replicate(ctx, "cv", RS_DEL_CMD, "cs", sp->name, argv[2]);
if (argc == 3) {
RedisModule_Replicate(ctx, RS_DEL_CMD, "cs", sp->name, argv[2]);
} else {
RedisModule_Replicate(ctx, RS_DEL_CMD, "csc", sp->name, argv[2], "dd");
}
return RedisModule_ReplyWithLongLong(ctx, rc);
}

Expand Down
41 changes: 41 additions & 0 deletions src/pytest/test_replicate.py
@@ -0,0 +1,41 @@
import subprocess
import os
import os.path
from RLTest import Env
import time

def testDelReplicate():
env = Env(useSlaves=True)
master = env.getConnection()
slave = env.getSlaveConnection()
env.assertContains("PONG", master.execute_command("ping"))
env.assertContains("PONG", slave.execute_command("ping"))

env.assertOk(master.execute_command('ft.create', 'idx', 'schema', 'f', 'text'))

for i in range(10):
master.execute_command('ft.add', 'idx', 'doc%d' % i, 1.0, 'fields',
'f', 'hello world')

time.sleep(5)
ashtul marked this conversation as resolved.
Show resolved Hide resolved

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertTrue(found)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mnunberg remove found all together

for i in range(10):
# checking for insertion
env.assertEqual(['f', 'hello world'],
master.execute_command('ft.get', 'idx', 'doc%d' % i))
env.assertEqual(['f', 'hello world'],
slave.execute_command('ft.get', 'idx', 'doc%d' % i))

# deleting
env.assertEqual(1, master.execute_command(
'ft.del', 'idx', 'doc%d' % i, 'DD'))

time.sleep(5)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertFalse(found)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove found all together

for i in range(10):
# checking for deletion
env.assertEqual(None,
master.execute_command('ft.get', 'idx', 'doc%d' % i))
env.assertEqual(None,
slave.execute_command('ft.get', 'idx', 'doc%d' % i))