A user, Blizzz, reports that User.find_by(id: 123) fails with a 404 error, even though the user’s profile is visible and lookup by username works. In the Rails console, the user’s ID is found via username_lower but not directly by ID. supermathie suspects PostgreSQL index corruption and suggests verifying the issue using direct SQL queries. Blizzz confirms it was indeed an index corruption issue and resolves it.
So, looking up via username works and it reveals the correct user id. But, looking up by user id does not result in the dataset. What can I do about it?