these tenses could both work in a context like this one.
"had __ed" refers to something earlier or completed. so, to refer to an EARLIER or DISCONTINUOUS interval, you'd use this tense.
consider:
• Ray had spent almost 20 years in prison before he died at the age of 90.
—> he could have served his sentence when he was much younger
—> he could have served 5 years at one time + 10 years at another time + 5 more years at another time
etc.
• Ray spent almost 20 years in prison before he died at the age of 90.
—> this means he spent his LAST twenty years incarcerated.
both interpretations could work here, too.