Both answers are correct. He had six goats remaining alive when speaking daily English.
And to get into needless confusing arguments about the "had past tense" proves nothing and only confuses learners.
It is normal therefore natural for English speakers to say, "that had" it has no reference to the fact of being n the past but refers in normal daily English to refer to past "ownership" he "had owned 17 sheep" then all but six died meaning he "had owned" all but six of the original 17.