Closed liuzhen closed 9 years ago
boss_db.erl:
transaction(TransactionFun, Timeout) -> Worker = poolboy:checkout(?POOLNAME, true, Timeout), State = gen_server:call(Worker, state, Timeout), put(boss_db_transaction_info, State), {reply, Reply, State} = boss_db_controller:handle_call({transaction, TransactionFun}, undefined, State), put(boss_db_transaction_info, undefined), poolboy:checkin(?POOLNAME, Worker), Reply.
If line {reply, Reply, State} = * raises an error, transaction info would not be cleared, then all the queries of this process would fail.
One occasion that raises an error at that line is:
pgsql.erl:
withtransaction(C, F) -> try {ok, [], []} = squery(C, "BEGIN"), R = F(C), {ok, [], []} = squery(C, "COMMIT"), R catch :Why -> squery(C, "ROLLBACK"), %% TODO hides error stacktrace {rollback, Why} end.
line of squery(C, "ROLLBACK") would fail if C terminated.
dup
boss_db.erl:
transaction(TransactionFun, Timeout) -> Worker = poolboy:checkout(?POOLNAME, true, Timeout), State = gen_server:call(Worker, state, Timeout), put(boss_db_transaction_info, State), {reply, Reply, State} = boss_db_controller:handle_call({transaction, TransactionFun}, undefined, State), put(boss_db_transaction_info, undefined), poolboy:checkin(?POOLNAME, Worker), Reply.
If line {reply, Reply, State} = * raises an error, transaction info would not be cleared, then all the queries of this process would fail.
One occasion that raises an error at that line is:
pgsql.erl:
withtransaction(C, F) -> try {ok, [], []} = squery(C, "BEGIN"), R = F(C), {ok, [], []} = squery(C, "COMMIT"), R catch :Why -> squery(C, "ROLLBACK"), %% TODO hides error stacktrace {rollback, Why} end.
line of squery(C, "ROLLBACK") would fail if C terminated.