Feature postgres deadlocks resolving

- resolves super unexpected issue with postgres deadlock
- changes database structure and session handling
- verifies if session is open on every upload request