Can't restore due to corrupt indexes (with some clues on how to deal with corrupt indexes)

This one also had two entries where ‘shiny-server’ matched only one but ‘%hiney-server’ matched both. I don’t see how this helps me to understand but I think you’re saying that the select I’m doing expects only one thing to be returned and pulls it from the index, ignoring the other, but when I use the % it searches the fields.

discourse=> EXPLAIN ANALYZE select * from tags where name='shiny-server'; 
                                                        QUERY PLAN                                                        
--------------------------------------------------------------------------------------------------------------------------
 Index Scan using index_tags_on_name on tags  (cost=0.28..8.29 rows=1 width=36) (actual time=0.038..0.040 rows=1 loops=1)
   Index Cond: ((name)::text = 'shiny-server'::text)
 Planning time: 0.129 ms
 Execution time: 0.070 ms
(4 rows)

I rather doubt that anyone who wouldn’t figure this out on their own will find this useful, but … I did a bunch of finding the two tag_ids with the same name and doing stuff like

 TopicTag.where(tag_id: 717).update_all(tag_id: 611)
 Tag.ensure_consistency!
 Tag.find(717) # make sure it's not in any topics
 Tag.find(717).destroy

and then doing a reindex table tags; in psql.

And it looks like now I’ll need to do it for users somewhat like @bartv described. Though with my users, I see one user David and another user david and also [Mm]ark.

Those I fixed like

marks=User.where("username similar to  '[Mm]+ark'").pluck(:id,:username,:created_at)

Then contrive to find the new mark in /admin/users and rename the user there. Then try to reindex table users; in psql. (sudo su - discourse and then psql).

4 Likes