It sounds to me that the composite key is not actually in place, and only the poll_id is the primary.
Run a describe on the table in question. Does it list that both the poll_id and answer_id are of type PRI for their keys? If these check out and list that the composite is in place, then the problem is you simply already have a record of 1 and 2 in the database before inserting OR your code is not updating the answer_id correctly before trying to insert it so that the second entry is trying to go in as 1 and 1 instead of 1 and 2.
I just noticed this is in the other databases forum. What database are you using; DESCRIBE is a proprietary MySQL command.