Subsequent PostgreSQL behavior after receiving "Terminate" ("X") after "COMMIT"

We start the postgres v9.2.8 server and use epgsql (erlang) as the client library. And in some cases that we had in production, but could not reproduce in the dev environment, we lose data.

The function in our application (it must be killed) allows the operator to change session parameters in the current connection. Since the connection is usually always busy with production, the query “SET SESSION bla-bla” always causes pgsql_connection to fail.

Before the failure, pgsql_connection sends a "Terminate" ("X") signal through pgsql_sock (the shell around the tcp socket) to the backend. At the same time, another erlang process (let him call it “worker”) is waiting for a response from the postgres backend using the same socket.

Now the question is: is it possible that after receiving the “Terminate” signal from the client, the backend can cancel the last transaction, even if it already sent “OK” to “COMMIT”?

Because if possible , the employee will have the opportunity to inform the main application process of the successful transaction, while the transaction was canceled.

Or, where can I find out more about this? The documentation says ( http://www.postgresql.org/docs/9.2/static/protocol-flow.html ):

, . , , , SELECT, , , . ( BEGIN... COMMIT) .

- .

+4
1

: , "Terminate" , "OK" "COMMIT"?

. . , , . "".

, Pg , , , synchronous_commit = off.

- , , , ( fork()) , , , .

, , , , . OK , (, ..) .


, , . . , - commit, , , .


/ , . , commit. , Pg, , , .

, , , PREPARE TRANSACTION, COMMIT PREPARED, XA API. , , , , "".

, commit, , - . TCP/IP , , commit Pg, , RST, . , , . , , , , , . , , , . -.

, , , , , , . , , " " , , II .

true 2PC:

  • , : " , ".

  • ;

  • , , .

... , 2 3 , 2 . , 2- , , , .

, XA, , ..

+1

Source: https://habr.com/ru/post/1546580/


All Articles