When two rows compare equal under the window’s ORDER BY, the numbering between them is arbitrary and MySQL is free to choose differently on the next execution.
-- two products with identical sales swap between runs
ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales DESC)
-- deterministic: nothing is ever equal
ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales DESC, sku)
-- and the three that disagree about ties:
-- ROW_NUMBER 1,2,3,4 RANK 1,2,2,4 DENSE_RANK 1,2,2,3
The symptom is a report that differs between two runs against unchanged data, which reads as a caching bug and is not one. Adding the primary key as a final sort column costs nothing and makes the result reproducible, which matters as soon as anybody compares two exports. Choosing between the three functions is a separate decision: “top three products” is ROW_NUMBER, “top three price tiers” is DENSE_RANK, and getting it wrong produces a report that is quietly incorrect rather than obviously broken.