Skip to content

Dropping an index and recreating causes duplicates if using a database other than 0 #37

Closed

Description

@pkmnfrk

Basically, FT.DROP doesn't seem to clean up all the keys it probably should if you're in a different database. We are running v0.10.

Here is a script that demonstrates the problem. The first time I run it, I get this output:

Recreate index:
OK

Add data:
OK
OK
OK

Index stats:
 1) index_name
 2) test
 3) fields
 4) 1) 1) body
       2) type
       3) TEXT
       4) weight
       5) "1"
 5) num_docs
 6) "3"
 7) max_doc_id
 8) "3"
 9) num_terms
10) "16"
11) num_records
12) "16"
13) inverted_sz_mb
14) "7.62939453125e-05"
15) inverted_cap_mb
16) "0"
17) inverted_cap_ovh
18) "inf"
19) offset_vectors_sz_mb
20) "1.52587890625e-05"
21) skip_index_size_mb
22) "0"
23) score_index_size_mb
24) "0"
25) doc_table_size_mb
26) "9.72747802734375e-05"
27) key_table_size_mb
28) "0.00010013580322265625"
29) records_per_doc_avg
30) "5.333333333333333"
31) bytes_per_record_avg
32) "5"
33) offsets_per_term_avg
34) "1"
35) offset_bits_per_record_avg
36) "8"

Query:
1) (integer) 1
2) "d1"
3) (empty list or set)

Drop index:
OK

However, the second time I run it, I get:

Query:
1) (integer) 2
2) "d1"
3) (empty list or set)
4) "d1"
5) (empty list or set)

A third time yields three results, etc.

If you edit the script to target db 0, then it behaves the way you expect.

Activity

  1. dvirsky commented on Mar 22, 2017

    @dvirsky
    Contributor

    It's a bug in redis itself (https://github.com/antirez/redis/issues/3851), so until further notice, please avoid using a db other than 0. This should be fixed before Redis 4.0. cc: @antirez

  2. dvirsky commented on Mar 22, 2017

    @dvirsky
    Contributor

    I'm keeping the issue open so we can discuss and verify it once the redis issue is sorted.

  3. pkmnfrk commented on Mar 22, 2017

    @pkmnfrk
    Author

    Good to know! Thanks!

  4. dvirsky commented on Mar 22, 2017

    @dvirsky
    Contributor

    While we're on the subject of warnings, please avoid using the module with AOF persistence. I should specify both of these somewhere indeed.

  5. pkmnfrk commented on Mar 22, 2017

    @pkmnfrk
    Author

    At the risk of exposing my Redis ignorance, you mean specifically AOF; i.e. regular RDP persistence is okay?

  6. dvirsky commented on Mar 22, 2017

    @dvirsky
    Contributor

    exactly. the default works just fine.

  7. pkmnfrk commented on Mar 22, 2017

    @pkmnfrk
    Author

    Got it! scribbles into deployment notes

  8. dvirsky commented on Jul 6, 2017

    @dvirsky
    Contributor

    The underlying redis issue has been fixed, this should be fine with latest redis unstable.

  9. TvoroG commented on Jul 16, 2018

    @TvoroG

    Hi, @dvirsky! I still cannot create index with db != 0. How can I fix this problem? Should I just remove these lines?

  10. dvirsky commented on Jul 16, 2018

    @dvirsky
    Contributor

    You just can't. ¯\(ツ)/¯

  11. added a commit that references this issue on Oct 7, 2020
  12. added a commit that references this issue on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions