> 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://www.postgresql.org/docs/current/static/explicit-locking.html