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

index variable is a string but is used as a dict ("string indices must be integers") #250

Open
smiranda opened this issue Feb 15, 2021 · 3 comments

Comments

@smiranda
Copy link

query.db(index["db"])

This happened to me when I killed a reindexation process than started again: the code throws the error "string indices must be integers" and i found is in that line.

To workaround I commented that part of the script and ran. Later I plan to manually delete the temporary index.

@lsabi
Copy link
Contributor

lsabi commented Feb 16, 2021

Probably it's due to how the index is saved during the reindexation.

We'll give it a look, but can you provide some more context on how to reproduce it? Thanks

@smiranda
Copy link
Author

Hello @lsabi , thanks for the reply.

I think it boils down to this. This command returns a list of strings and not a list of objects. So index is a string.

for index in options.retryQuery(
            "list indexes on %s.%s" % (db, table),
            query.db(db).table(table).index_list(),
        ):

Therefore this other command which is inside of the loops probably needs to be modifed as such:

options.retryQuery(
                    "drop index: %s.%s:%s" % (db, table, index),
                    query.db(index["db"]) # replace index["db"] with db
                    .table(index["table"]) # replace index["table"] with table
                    .index_drop(index["name"]), # replace index["name"] with index
                )

So during indexation rethinkDB creates "$reql_temp_index$" for the indexes it's reindexing. If you interrupt the reindexation these indexes will stay there. The existence of these indexes in this python script I referred triggers this cleanup code. So this cleanup code probably runs rarely, and it crashes.

If you see line

if index.startswith(TMP_INDEX_PREFIX):
it means the var index was already expected to be a string, not a dict, as it's being used in lines 129,130 and 131. So it just seems a typo.

@lsabi
Copy link
Contributor

lsabi commented Feb 20, 2021

I'll try to dig into it as soon as I have some spare time to dedicate.

In the meantime I would keep it open. If you have more feedbacks, just right them here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants