Will this SQL snippet REINDEX my GIN index? Why is it renaming an old index onto another?
Look at the names more carefully.  pgcompact_temp_index_17791 and pgcompact_index_17791 are not the same thing.

The reason to rename the old index is that you can't do "drop index concurrently" inside of a transaction.