ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction...

59

Transcript of ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction...

Page 1: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Transactions Across Multiple DatastorespgConf.eu Tallinn 2016

Cédric Villemain [email protected]

Nov. 3, 2016

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 1 / 27

Page 2: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Cédric Villemain

PostgreSQL Expertise & Development

Training24x7 Support & RDBA

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 2 / 27

Page 3: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

2ndQuadrant

PostgreSQL Platinum Sponsor

• 9.2, group commit improvment

• 9.3, checksum on data pages

• 9.4, logical decoding

• 9.5, track_commit_timestamp

• 9.6, 2PC performances improvment

• 9.4 - NEXT, Bi-Directionnal Replication

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 3 / 27

Page 4: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Datastore

• Filesystem

• IMAP

• LDAP

• Key-Value Store

• RelationnalDatabase

It is a way of �storing bytes�

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 4 / 27

Page 5: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Datastore

• Filesystem

• IMAP

• LDAP

• Key-Value Store

• RelationnalDatabase

It is a way of �storing bytes�

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 4 / 27

Page 6: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Datastore

• Filesystem

• IMAP

• LDAP

• Key-Value Store

• RelationnalDatabase

It is a way of �storing bytes�

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 4 / 27

Page 7: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Datastore

• Filesystem

• IMAP

• LDAP

• Key-Value Store

• RelationnalDatabase

It is a way of �storing bytes�

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 4 / 27

Page 8: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Datastore

• Filesystem

• IMAP

• LDAP

• Key-Value Store

• RelationnalDatabase

It is a way of �storing bytes�

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 4 / 27

Page 9: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Datastore

• Filesystem

• IMAP

• LDAP

• Key-Value Store

• RelationnalDatabase

It is a way of �storing bytes�

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 4 / 27

Page 10: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Datastore

• Filesystem

• IMAP

• LDAP

• Key-Value Store

• RelationnalDatabase

It is a way of �storing bytes�

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 4 / 27

Page 11: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Transactions

ACID

Atomicity Consistency Isolation Durability

not BASE

Basically Available, Soft state, Eventual consistency

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 5 / 27

Page 12: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Transactions

ACID

Atomicity Consistency Isolation Durability

not BASE

Basically Available, Soft state, Eventual consistency

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 5 / 27

Page 13: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Transactions

ACID

Atomicity Consistency Isolation Durability

not BASE

Basically Available, Soft state, Eventual consistency

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 5 / 27

Page 14: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Transactions

ACID

Atomicity Consistency Isolation Durability

not BASE

Basically Available, Soft state, Eventual consistency

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 5 / 27

Page 15: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Transactions

ACID

Atomicity Consistency Isolation Durability

not BASE

Basically Available, Soft state, Eventual consistency

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 5 / 27

Page 16: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Transactions

ACID

Atomicity Consistency Isolation Durability

not BASE

Basically Available, Soft state, Eventual consistency

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 5 / 27

Page 17: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Accross

Transaction on each datastore

Global Transaction accross multiple datastores

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 6 / 27

Page 18: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Accross

Transaction on each datastore

Global Transaction accross multiple datastores

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 6 / 27

Page 19: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

PATTERNS

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 7 / 27

Page 20: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Complex Transaction

I want to check warehouse, check for payment, do the sale, validatepayment, send items, and update stocks.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 8 / 27

Page 21: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Digital Safe

I must have double transaction: original plus legal one on a distinct safe.Online gambling website look at that.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 9 / 27

Page 22: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Distinct Datastores

Distinct datastore per activity, optionnaly with distinct technology.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 10 / 27

Page 23: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

TECHS

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 11 / 27

Page 24: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

PostgreSQL

Foreign Data Wrappers allows to commit transactions on distinctdatastores.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 12 / 27

Page 25: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

PostgreSQL

CREATE TABLE demo (

id serial primary key, d timestamptz, t text, i int

);

CREATE FOREIGN TABLE f_demo (

id serial, d timestamptz, t text, i int

) SERVER loopback OPTIONS (table_name 'demo');

BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE ;

TABLE demo;

TABLE f_demo;

INSERT INTO f_demo values (1, now(), 'remote insert', 1);

INSERT INTO demo values (2, now(), 'local insert', 2);

COMMIT;

ERROR: could not serialize access due to read/write

dependencies among transactions

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 13 / 27

Page 26: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

PostgreSQL

CREATE TABLE demo (

id serial primary key, d timestamptz, t text, i int

);

CREATE FOREIGN TABLE f_demo (

id serial, d timestamptz, t text, i int

) SERVER loopback OPTIONS (table_name 'demo');

BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE ;

TABLE demo;

TABLE f_demo;

INSERT INTO f_demo values (1, now(), 'remote insert', 1);

INSERT INTO demo values (2, now(), 'local insert', 2);

COMMIT;

ERROR: could not serialize access due to read/write

dependencies among transactions

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 13 / 27

Page 27: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

PostgreSQL

TABLE demo;

id | d | t | i

----+-------------------------------+---------------+---

1 | 2016-11-02 18:59:13.207825+01 | remote insert | 1

NEXT: add a 2 Phase Commit to rollback remote transactions ? (at least)

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 14 / 27

Page 28: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

PostgreSQL

TABLE demo;

id | d | t | i

----+-------------------------------+---------------+---

1 | 2016-11-02 18:59:13.207825+01 | remote insert | 1

NEXT: add a 2 Phase Commit to rollback remote transactions ? (at least)

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 14 / 27

Page 29: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Logical Replication

Distributed/Spread accros several datastores, BASE by default.

Use synchronous replication (including replay) to reach ACID!

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 15 / 27

Page 30: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Logical Replication

Distributed/Spread accros several datastores, BASE by default.

Use synchronous replication (including replay) to reach ACID!

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 15 / 27

Page 31: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Compensation or Rollback transaction

Those solutions are complex and most of the time require a Transaction

Compensation instead of a Rollback.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 16 / 27

Page 32: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Two Phase Commit

Problem: be sure as much as possible that commit will be successfull !

Solution: two-phase commit protocol

Transaction Manager

START

DEFINE XIDs

1/ PREPARE

...

2/ COMMIT/ROLLBACK

Transaction A

BEGIN

...SOME SQL...

PREPARE TRANSACTION

...

COMMIT PREPARED

Transaction B

BEGIN

...SOME SQL...

PREPARE TRANSACTION

...

COMMIT PREPARED

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 17 / 27

Page 33: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Two Phase Commit

Problem: be sure as much as possible that commit will be successfull !

Solution: two-phase commit protocol

Transaction Manager

START

DEFINE XIDs

1/ PREPARE

...

2/ COMMIT/ROLLBACK

Transaction A

BEGIN

...SOME SQL...

PREPARE TRANSACTION

...

COMMIT PREPARED

Transaction B

BEGIN

...SOME SQL...

PREPARE TRANSACTION

...

COMMIT PREPARED

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 17 / 27

Page 34: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

X/Open DTP Distributed Transaction ProcessingX/Open XA eXtended Architecture

XA propose 3 layers to handle Global Transactions

• APPlication

• Resource Manager

• Transaction Manager

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 18 / 27

Page 35: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

X/Open DTP Distributed Transaction ProcessingX/Open XA eXtended Architecture

XA propose 3 layers to handle Global Transactions

• APPlication

• Resource Manager

• Transaction Manager

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 18 / 27

Page 36: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

X/Open DTP Distributed Transaction ProcessingX/Open XA eXtended Architecture

XA propose 3 layers to handle Global Transactions

• APPlication

• Resource Manager

• Transaction Manager

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 18 / 27

Page 37: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

• Asynchronous Operations

• Suspend Transaction

• Migrate Transaction

• Join Transaction

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 19 / 27

Page 38: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

• Asynchronous Operations

• Suspend Transaction

• Migrate Transaction

• Join Transaction

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 19 / 27

Page 39: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

• Asynchronous Operations

• Suspend Transaction

• Migrate Transaction

• Join Transaction

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 19 / 27

Page 40: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

• Asynchronous Operations

• Suspend Transaction

• Migrate Transaction

• Join Transaction

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 19 / 27

Page 41: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Asynchronous Operation

Purpose is to have Transaction Manager and, if relevant, APPlication beable to do other processing instead of just waiting.

PostgreSQL o�ers asynchronous operations with libpq

https://www.postgresql.org/docs/current/static/libpq-async.html

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 20 / 27

Page 42: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Asynchronous Operation

Purpose is to have Transaction Manager and, if relevant, APPlication beable to do other processing instead of just waiting.

PostgreSQL o�ers asynchronous operations with libpq

https://www.postgresql.org/docs/current/static/libpq-async.html

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 20 / 27

Page 43: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Suspend Transaction

It is ... just like a �pause�. But you can disconnect.

Partial support from PostgreSQL (�idle in transaction� if you prefer)

Option to con�gure a timeout: idle_in_transaction_session_timeout

PgBouncer

A patch for pgbouncer complete this feature by providing the client the abilityto disconnect and reconnect later to resume its transaction.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 21 / 27

Page 44: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Suspend Transaction

It is ... just like a �pause�. But you can disconnect.

Partial support from PostgreSQL (�idle in transaction� if you prefer)

Option to con�gure a timeout: idle_in_transaction_session_timeout

PgBouncer

A patch for pgbouncer complete this feature by providing the client the abilityto disconnect and reconnect later to resume its transaction.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 21 / 27

Page 45: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Suspend Transaction

It is ... just like a �pause�. But you can disconnect.

Partial support from PostgreSQL (�idle in transaction� if you prefer)

Option to con�gure a timeout: idle_in_transaction_session_timeout

PgBouncer

A patch for pgbouncer complete this feature by providing the client the abilityto disconnect and reconnect later to resume its transaction.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 21 / 27

Page 46: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Migrate transaction

It is an interesting feature:TM can complete work (for example just issue a PREPARE TRANSACTIONon behalf of the APP when APP asks it to do so)And it allows APP to resume the transaction with another transaction branch(that is: another �client�)

PgBouncer

This is not natively supported by PostgreSQL but a patch to pgbouncerallows that.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 22 / 27

Page 47: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Migrate transaction

It is an interesting feature:TM can complete work (for example just issue a PREPARE TRANSACTIONon behalf of the APP when APP asks it to do so)And it allows APP to resume the transaction with another transaction branch(that is: another �client�)

PgBouncer

This is not natively supported by PostgreSQL but a patch to pgbouncerallows that.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 22 / 27

Page 48: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Join transaction

It is also an interesting feature: several clients can issue queries on the sametransaction, and allowing the RM to serialize them the way it wants.

PgBouncer

This is not natively supported by PostgreSQL but a patch to pgbouncerallows that.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 23 / 27

Page 49: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Join transaction

It is also an interesting feature: several clients can issue queries on the sametransaction, and allowing the RM to serialize them the way it wants.

PgBouncer

This is not natively supported by PostgreSQL but a patch to pgbouncerallows that.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 23 / 27

Page 50: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Recover transactions

This is about prepared transaction, and also already commited transaction.

PostgreSQL o�ers both options

one is easy:

SELECT transaction, gid, prepared, owner, database

FROM pg_prepared_xacts

this other is less convenient to use but is o�ered by logical slot and WALexploration (pg_xlogdump is an example).

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 24 / 27

Page 51: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Recover transactions

This is about prepared transaction, and also already commited transaction.

PostgreSQL o�ers both options

one is easy:

SELECT transaction, gid, prepared, owner, database

FROM pg_prepared_xacts

this other is less convenient to use but is o�ered by logical slot and WALexploration (pg_xlogdump is an example).

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 24 / 27

Page 52: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

open/XA Features

Recover transactions

This is about prepared transaction, and also already commited transaction.

PostgreSQL o�ers both options

one is easy:

SELECT transaction, gid, prepared, owner, database

FROM pg_prepared_xacts

this other is less convenient to use but is o�ered by logical slot and WALexploration (pg_xlogdump is an example).

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 24 / 27

Page 53: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

PostgreSQL driver for XA

PostgreSQL JDBC include a support for XA (partial).

libpqXA is a C driver extending libpq for supporting open/XA. It includesall of the required API:

int (*xa_open_entry)(char *, int, long);

int (*xa_close_entry)(char *, int, long);

int (*xa_start_entry)(XID *, int, long);

int (*xa_end_entry)(XID *, int, long);

int (*xa_rollback_entry)(XID *, int, long);

int (*xa_prepare_entry)(XID *, int, long);

int (*xa_commit_entry)(XID *, int, long);

int (*xa_recover_entry)(XID *, long, int,

int (*xa_forget_entry)(XID *, int, long);

int (*xa_complete_entry)(int *, int *, int, long);

PgBouncer still required to handle advanced features.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 25 / 27

Page 54: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

PostgreSQL driver for XA

PostgreSQL JDBC include a support for XA (partial).

libpqXA is a C driver extending libpq for supporting open/XA. It includesall of the required API:

int (*xa_open_entry)(char *, int, long);

int (*xa_close_entry)(char *, int, long);

int (*xa_start_entry)(XID *, int, long);

int (*xa_end_entry)(XID *, int, long);

int (*xa_rollback_entry)(XID *, int, long);

int (*xa_prepare_entry)(XID *, int, long);

int (*xa_commit_entry)(XID *, int, long);

int (*xa_recover_entry)(XID *, long, int,

int (*xa_forget_entry)(XID *, int, long);

int (*xa_complete_entry)(int *, int *, int, long);

PgBouncer still required to handle advanced features.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 25 / 27

Page 55: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Summary

open/XA is a good standard for managing ACID transaction on multipledatastores.PostgreSQL has 2PC in-core. Missing features are covered by external toolpgBouncer.libpqXA is an extension to libpq for supporting open/XA in C and C++.

The complete solution including libpqXA and improved pgBouncer is in useat Bibliothèque Nationnale de France ( http://www.bnf.fr/ ) whosponsored the open-source development.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 26 / 27

Page 56: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Summary

open/XA is a good standard for managing ACID transaction on multipledatastores.PostgreSQL has 2PC in-core. Missing features are covered by external toolpgBouncer.libpqXA is an extension to libpq for supporting open/XA in C and C++.

The complete solution including libpqXA and improved pgBouncer is in useat Bibliothèque Nationnale de France ( http://www.bnf.fr/ ) whosponsored the open-source development.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 26 / 27

Page 57: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Summary

open/XA is a good standard for managing ACID transaction on multipledatastores.PostgreSQL has 2PC in-core. Missing features are covered by external toolpgBouncer.libpqXA is an extension to libpq for supporting open/XA in C and C++.

The complete solution including libpqXA and improved pgBouncer is in useat Bibliothèque Nationnale de France ( http://www.bnf.fr/ ) whosponsored the open-source development.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 26 / 27

Page 58: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Summary

open/XA is a good standard for managing ACID transaction on multipledatastores.PostgreSQL has 2PC in-core. Missing features are covered by external toolpgBouncer.libpqXA is an extension to libpq for supporting open/XA in C and C++.

The complete solution including libpqXA and improved pgBouncer is in useat Bibliothèque Nationnale de France ( http://www.bnf.fr/ ) whosponsored the open-source development.

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 26 / 27

Page 59: ransacTtions Across Multiple Datastores - PostgreSQL · And it allows APP to resume the transaction with another transaction branch (that is: another client ) PgBouncer This is not

Any questions ?

Please ask !

Cédric Villemain [email protected] Transactions Across Multiple Datastores Nov. 3, 2016 27 / 27