Dustin Sallings <dustin+pgsql@spy.net> writes:
> It's not clear to me why this should deadlock. I don't believe
> any of the async log events that were being recorded were referencing the
> new ID (and if they were, I'd think they'd fire an RI violation).
When you insert a new row into a table that has RI references, the
referenced rows in the other table are locked down with SELECT FOR
UPDATE locks (to ensure they won't be deleted before your own
transaction can commit). I am not sure that this could explain your
deadlock, but it seems like the first place to look.
regards, tom lane