You can change the SQL query as follow to randomly select 5 persons from the table:
select distinct person_id
from (select person_id from customers order by random()) foo
You need to select without the distinct clause, randomize the results, and then use select with the distinct clause. The above SQL will not give the error.