Skip to content

backend: migration for recreating invite index#3328

Open
mistydemeo wants to merge 1 commit into
mainfrom
misty/migration_drop_recreate_index
Open

backend: migration for recreating invite index#3328
mistydemeo wants to merge 1 commit into
mainfrom
misty/migration_drop_recreate_index

Conversation

@mistydemeo
Copy link
Copy Markdown
Contributor

I neglected to recreate the index when changing the expiration in #3284. We always create the indices on startup, not as a part of the migrations, but this will fail with a runtime error if the database already has this index with a different value in it.

Fixes #3327.

I neglected to recreate the index when changing the expiration in #3284.
We always create the indices on startup, not as a part of the migrations,
but this will fail with a runtime error if the database already has this
index with a different value in it.

Fixes #3327.
Copy link
Copy Markdown
Member

@tw4l tw4l left a comment

Choose a reason for hiding this comment

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

Thanks!

There is a bit of redundancy here, as the index will get dropped and then rebuilt again after this (or any) migration runs: https://github.com/webrecorder/browsertrix/blob/main/backend/btrixcloud/db.py#L164. We used to do this routine of dropping the indexes on every startup and later modified it to only drop the indexes if new migrations actually ran.

So we could alternatively merge the new migration in #3113 instead, and that should fix the issue as well.


# pylint: disable=unused-argument
def __init__(self, mdb: AsyncIOMotorDatabase, **kwargs):
self.mdb = mdb
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
self.mdb = mdb

This shouldn't be necessary, it will get set in the BaseMigration.__init__() call on the next line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh good to know - I based this on one of the other migrations that did this, but now that I check the others that use self.mdb didn't assign it.

@mistydemeo
Copy link
Copy Markdown
Contributor Author

There is a bit of redundancy here, as the index will get dropped and then rebuilt again after this (or any) migration runs

Aha, I was wondering about that! I did see the indices get bulk dropped/rebuilt in the logs when testing this, but it happening on any other migration explains it. Happy to just go with that other one assuming it's ready to go now. Two birds with one migration, etc

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

Successfully merging this pull request may close these issues.

[Bug]: Invites index needs to be recreated after changing expiration

2 participants