404 on term taxonomy archive pagination only with some terms

user2660802 reports that the problem has been resolved thanks to using Pieter Goosen’s suggestion of using pre_get_posts instead of query_posts().

query_posts() breaks the main query, it is slow, and totally stuffs
up pagination.