See this answer here for the source that there is no pain when dying Al Kiddush Hashem. How then can we understand these following medrashim?
The fact that when Reb Chanina ben Tradyoin was being burned alive he requested that they remove the wet towels which were prolonging his death. This would show that he indeed in pain. The second proof was from Reb Akiva whose Talmidim asked him how he could concentrate on the Shema when in such agony (from the iron combs that they raked his skin with). Again this shows that he was in pain. See Gemara Avodah Zarah 18a the last page of this pdf. Both these show that pain does indeed exist?