Use Postgresql transactions
Some database calls are supposed to be atomic but are done sequentially instead. This is especially dangerous considering there is not yet any graceful shutdown (#25 (closed)).
I can see some bad behaviours:
- Deleting objects (that were just created in a parent function) in case of error: transactions should just be aborted instead.
- Concurrency on objects partially written.
- Almost no error checks for database read/write operations.