PostgreSQL: infinite DECLARE CURSOR when rebuilding one Elasticsearch index

My logs show nothing at all. I have slow logs enabled for indexing, but they are empty. The general elasticsearch log shows nothing specific. There are no helath issues either.

My code is just as described above. The mapping consists of only one field, the data for this field is indexed as is, without any preparation.

Here is the python document code for django:

@registry.register_document
class DocKey(Document):
    class Index:
        name = 'doc_keys'
        settings = {'number_of_shards': 1,
                    'number_of_replicas': 0}

    class Django:
        model = DocKey
        fields = [
            'keyword',
        ]

        ignore_signals = True
        auto_refresh = False

Again, all had been working but somehow broke down, and only for one specific index.