The problem is on the sequence (and you can't lock a sequence) not on the table. I would explicit lock the table (access exclusive mode is fine) or, better, I would get (i.e. book) a bunch of ids  (```select nextval('your_sequence') from generate_series(1, len(data)```) to use it.