fix(tasks): reindex users after IP cleanup#556
Open
Samk13 wants to merge 1 commit into
Open
Conversation
e418808 to
1f758ef
Compare
Samk13
commented
Jun 11, 2026
| User.updated: db.func.now(), | ||
| # User indexing uses version_id as the record revision, so | ||
| # bulk changes must advance it to replace the search doc. | ||
| User.version_id: User.version_id + 1, |
Member
Author
There was a problem hiding this comment.
I added the version_id bump because mark_changed() alone scheduled the reindex, but did not reliably replace the indexed user document.
My main concern is concurrent user updates while this task runs, since bumping version_id can trigger optimistic-lock conflicts for in-flight ORM updates.
If ther's a better way to force user reindexing without touching User.version_id, I'm happy to adjust.
* Update login IP cleanup to process expired records in batches and bump affected user versions. * Mark changed users through the datastore so search indexes stay in sync after IP removal. * Cover version updates and datastore change tracking in the IP cleanup task test.
1f758ef to
2b7e526
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
❤️ Thank you for your contribution!
Description
As requested:
For an easier review, here is how to test the changes:
Seed DB values: see here
uv run invenio shell scripts/dev/user-check-tools/seed_users_login_info.pyRebuild user index so DB and OpenSearch start aligned: see here
uv run invenio shell scripts/indices-migration-v13-14/user-groups-indices-migration.pyCheck baseline: see here
uv run invenio shell scripts/dev/user-check-tools/check_users_login_info_index.pyRun the task with
invenio shellrun step 3 again and check the difference, or check with curl:
Check the screenshot before and after running the script to see the number of users in db and indices should match.
Before and after running the task:
Before
After
Checklist
Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:
Frontend
Reminder
By using GitHub, you have already agreed to the GitHub’s Terms of Service including that: