def _maybe_clean_pg_replslot(self) -> None:
        """Clean pg_replslot directory if pg version is less then 11
        (pg_rewind deletes $PGDATA/pg_replslot content only since pg11)."""
        if self._postgresql.major_version < 110000:
            replslot_dir = self._postgresql.slots_handler.pg_replslot_dir
            try:
                for f in os.listdir(replslot_dir):
                    shutil.rmtree(os.path.join(replslot_dir, f))
                fsync_dir(replslot_dir)
            except Exception as e:
                logger.warning('Unable to clean %s: %r', replslot_dir, e)
Clean pg_replslot directory if pg version is less then 11
        (pg_rewind deletes $PGDATA/pg_replslot content only since pg11).
patroni/postgresql/rewind.py