partitioning – A strange index that is always marked pg_index.indisvalid=false . Why indexes with ON ONLY option are always rebuilt in invalid state?

I’m looking in database (postresql 11.10) and see an index on a partitioned table that marked as invalid:

SELECT 
        indrelid::regclass, indexrelid::regclass, indisvalid, ddlx_create_index(indexrelid)
    FROM 
        pg_catalog.pg_index 
    WHERE
        indrelid = 'document'::regclass
        AND NOT indisvalid 
indrelid indexrelid indisvalid ddlx_create_index
document ix_doc_file false CREATE INDEX ix_doc_file ON ONLY public.document USING btree (file) INCLUDE (document_type);

If I do:

DROP INDEX ix_doc_file;
CREATE INDEX ix_doc_file ON ONLY public.document USING btree (file) INCLUDE (document_type);

this index is created/reindexed without any warnings but again in invalid state.

What’s the most strange is that I can’t find nothing extraordinary in this index.

On the same table similar indexes exists:

indrelid indexrelid indisvalid ddlx_create_index
document ix_doc_org_id_idx true CREATE INDEX ix_doc_org_id_idx ON ONLY public.document USING btree (org_id);
document ix_doc_last_modified_user_idx true CREATE INDEX ix_doc_last_modified_user_idx ON ONLY public.document USING btree (last_modified_user);
document ix_document_file_document_flags true CREATE INDEX ix_document_file_document_flags ON ONLY public.document USING btree (file) INCLUDE (document_flags);

As you can see one of valid indexes is almost the same:

CREATE INDEX ix_document_file_document_flags ON ONLY public.document USING btree (file) INCLUDE (document_flags);

The only difference is that document_type is text and document_flags is bigint.

(it’s completely another question that maybe some indexes are not needed)

I’m puzzled: What could prevent rebuilding index in valid state?

Notes:

  • instance is not under load
  • it’s not a production server
  • IDK if it matters but that’s Amazon RDS Postgresql 11.10
  • it’s an index on partitioned table

I will be grateful for any ideas for where to look.

UPDATE

The culprit was the option ON ONLY.

So: any index built with ON ONLY option is invalid.

If I remove ON ONLY then index successfully rebuilt with valid status.

So updated question is: why indexes with ON ONLY option are always invalid?