Hmm. Consider that the first time relcahe invalidation occurs while computing id_attrs, so now the retry logic will compute the correct set of attrs (considering two indexes, if we take the example given by Alvaro above.).
I don't quite get that. Since rd_idattr must be already cached at that point and we don't expect to process a relcache flush between successive calls to RelationGetIndexAttrBitmap(), we should return a consistent copy of rd_idattr. But may be I am missing something.