Fix transaction errors in postgres