Automatic vacuum fails with `ERROR: XX000: cache lookup failed for type 0`
As your investigation uncovered, you are suffering from this PostGIS bug (bug number #4440).

Your options:


Update PostGIS to the latest minor release. The bug has been fixed in June 2019.
Workaround: Use GiST rather than SP-GiST indexes.