Redisearch: "Document already exists" error with "REPLACE" option

Created on 31 Jul 2019  路  4Comments  路  Source: RediSearch/RediSearch

I saw a "document already exists" error on a FT.ADD command with REPLACE option set. If I understand correctly, that error should never occur with REPLACE set?

It occurred while the client was bulk-indexing in parallel (using Parallel gem). Each thread was indexing a distinct set of documents, but is it possible there's a race condition that caused the error to occur? I only saw it once, which made me think it's a weird corner case.

This was on v1.4.5, Redis 5.0.4.

bug

All 4 comments

@mahemoff thanks for reporting. I will try to reproduce locally with some concurrent add operation. Will update here if/when I will success..

@mahemoff did it reproduced sense you reported it?

I haven't been monitoring it tbh. I did see it a few times on that day, though seems to be rare. I'll let you know if I do see it again.

Reproducible with this script:

In [18]: def Test(): 
    ...:     import redis 
    ...:     r = redis.Redis() 
    ...:     for j in range(10000):  
    ...:        query = ['ft.add', 'idx', 'doc%d'%j, '1.0', 'REPLACE', 'FIELDS']  
    ...:        query += ['f1', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f2', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f3', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f4', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f5', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f6', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f7', ','.join([str(a) for a in range(7000)])]  
    ...:        r.execute_command(*query) 

In [18]: def Test(): 
    ...:     import redis 
    ...:     r = redis.Redis() 
    ...:     for j in range(10000):  
    ...:        query = ['ft.add', 'idx', 'doc%d'%j, '1.0', 'REPLACE', 'FIELDS']  
    ...:        query += ['f1', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f2', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f3', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f4', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f5', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f6', ','.join([str(a) for a in range(7000)])]  
    ...:        query += ['f7', ','.join([str(a) for a in range(7000)])]  
    ...:        r.execute_command(*query) 

start() 
Was this page helpful?
0 / 5 - 0 ratings

Related issues

cit68 picture cit68  路  8Comments

drittich picture drittich  路  11Comments

ethan-tr picture ethan-tr  路  8Comments

martinmakesitwork picture martinmakesitwork  路  4Comments

ethanhann picture ethanhann  路  6Comments