3

I'm using session with a room reservation app that uses SQL Alchemy. The app until now works fine, but, I tested with 2 persons using it at the same time, using different user accounts, and the reserves can be done at the same room, and hour of the day.

This didn't happen when using just one account, i tested the room check code a lot, so must be a concurrency problem (both users use the check when is empty and the make it). I'm using PostgreSQL as DBMS, is there a way lock the table while making the commit to the DB and then unlock it when it's done??

4

1 回答 1

2

这正是发明排除约束的那种情况。当 9.2 发布时,您将能够将它们与timestamptz 范围一起使用;对于 9.0 和 9.1 版本,您需要安装temporalbtree_gist模块。

有关更多信息,请参阅Jeff Davis 的这篇博客文章,他提出了这个想法并实施了它。

于 2012-08-24T01:42:00.057 回答