> Could I use lock tables to fix this? Is postgres automaticaly locking a> table while running a trigger on that table?
You can use LOCK TABLE. See the documentation:
http://stream.boxwatch.ru/docs/current/static/explicit-locking.html