SlideShare a Scribd company logo
1 of 20
Download to read offline
© 2013 EDB All rights reserved. 1
Atomicity for transactions involving
foreign servers
•
Ashutosh Bapat | 19th
June 2015
@PGCon 2015, Ottawa, Canada
© 2013 EDB All rights reserved. 2
•
Atomic commit for transactions involving foreign
servers
– Current status
– Solution – two-phase commit protocol
– Overview of implementation
– Foreign servers without 2PC support
•
Atomic visibility
Agenda
© 2013 EDB All rights reserved. 3
Atomicity
val
1
2
tab1
val
1
2
tab2
BEGIN;
UPDATE tab1 SET val = val + 1;
UPDATE tab2 SET val = val + 2;
COMMIT;
val
1
2
tab1
val
1
2
tab2
val
2
3
tab1
val
3
4
tab2
success
val
2
3
tab1
val
1
2
tab2
failure
© 2013 EDB All rights reserved. 4
Distributed Atomicity
val
1
2
tab1
val
1
2
tab2
BEGIN;
UPDATE tab1 SET val = val + 1;
UPDATE tab2 SET val = val + 2;
COMMIT;
val
1
2
tab1
val
1
2
tab2
val
2
3
tab1
val
3
4
tab2
val
2
3
tab1
val
1
2
tab2
Coordinator
FS 1 FS 2
FDW FDW
failure
success
© 2013 EDB All rights reserved. 5
Atomicity - foreign table inheritance
val
1
2
chld1
val
1
2
chld2
UPDATE parent SET val = val + 1;
val
1
2
tab1
val
1
2
tab2
val
2
3
tab1
val
2
3
tab2
val
2
3
tab1
val
1
2
tab2
Coordinator
FS 1 FS 2
FDW FDW
failure
success
parent
© 2013 EDB All rights reserved. 6
•
Transaction management is entirely implemented by
FDW
– postgres_fdw uses one-phase commit
– any failure (including connectivity) during commit
processing can cause changes to some foreign
servers committed and others aborted
•
Atomicity is not guaranteed
Current status
© 2013 EDB All rights reserved. 7
Two-phase commit
Prepare transaction
on foreign server
Prepare
succeeded?
Next foreign
server?
yes
yes
Commit all prepared
transactions.
No
Abort all prepared
transactions
Abort any
unprepared
transactions
No
Phase 1
Phase 2
failure
Commit processing,
record commit locally
Local pre-commit
processing
© 2013 EDB All rights reserved. 8
Two-phase commit
Prepare transaction on foreign server
Prepare succeeded?
Next foreign server?
yes
yes
Commit all prepared
transactions.
No
Abort all prepared
transactions
Abort any unprepared transactions
No
Phase 1
Phase 2
Connectivity failure, coordinator/foreign server crash
•
all the foreign transactions and local transaction may not commit at the
same time
– Atomic commit – guaranteed
– Atomic visibility – not guaranteed
•
Unresolved prepared transactions – prepared transactions waiting to be
committed/aborted
– Blocked resources, degraded performance
© 2013 EDB All rights reserved. 9
Remembering foreign transactions
Log about prepared
transactions
Persist prepared
transaction information
to disk
Prepare transaction on
foreign server
Get prepared
transaction information
pg_fdw_xact/
XLOG
In-memory array
Crash
recovery,
replication
Server restarts
Prepare transaction on
foreign server
© 2013 EDB All rights reserved. 10
Resolving foreign transactions
Log the removal of
foreign transaction
information
Remove foreign
transaction from the
disk
Commit/Abort foreign
transaction
pg_fdw_xact/
XLOG
In-memory array
Crash
recovery,
replication
Commit/abort foreign
transaction
Successful?
Yes
No
Retried by
resolver till
resolved
© 2013 EDB All rights reserved. 11
•
Transaction id: decides the fate of foreign transaction
•
Database id: where to look for foreign server and user
mapping
•
Foreign server and user: where and who prepared the
foreign transaction
•
Foreign transaction id: identifies the prepared
transaction on the foreign server
– e.g. GID on PostgreSQL
Foreign transaction information
© 2013 EDB All rights reserved. 12
Foreign servers without 2PC support
Commit
transaction on
foreign server
Successful?
Next
foreign
server?
No
No
Yes
Yes
Transaction
aborted on
foreign
server
Local
commit
successful?
Yes
Abort transaction
on all foreign
servers
No
Commit
transaction on
foreign server
Successful?
Next
foreign
server?
No
No
Yes
Yes
Precommit
processing
successful?
Yes
Abort transaction
on all remaining
foreign servers
No
Vs
© 2013 EDB All rights reserved. 13
•
GetPrepareId
– function to obtain prepared transaction id for a
given foreign server
– Each FDW might have different rules for identifier
– Persisted and WAL logged
FDW hooks for transaction management
© 2013 EDB All rights reserved. 14
•
HandleForeignTransaction - function to end foreign
transaction in following ways
– Commit/Rollback running transaction
– Prepare running transaction
– Commit/Rollback prepared transaction with given
identifier
FDW hooks for transaction management
© 2013 EDB All rights reserved. 15
•
atomic_foreign_transaction – when ON, two phase
commit is used for transactions involving foreign
servers.
– When ON requires all participating servers to
support 2PC
– Can be set any time during the transaction.Value
at the time of commit is used.
•
max_foreign_xacts – maximum number of transactions
prepared on foreign servers at a given time
GUCs
© 2013 EDB All rights reserved. 16
•
Builtin function (pg_fdw_resolve())– resolves all the
unresolved foreign transactions in the database where
it's run
•
Background worker process – fires the built-in function
by connecting to various databases
– Available at contrib/pg_fdw_xact_resolver
– Install and add to 'shared_preload_libraries' (and
restart)
Foreign transaction resolver
© 2013 EDB All rights reserved. 17
Atomic visibility
© 2013 EDB All rights reserved. 18
•
Problem: MVCC allows older versions to be read
– Older version of data is read while transaction
modifying it is prepared but not committed/resolved
•
Solution: Wait for prepared transactions to get
committed/resolved
– Stronger locking – FOR SHARE, SERIALISABLE
ISOLATION – performance affected
– Resolve prepared transactions before data is
accessed
●
You have connectivity now, right?
●
How to detect this situation?
Atomic visibility – rough ideas
© 2013 EDB All rights reserved. 19
•
Hackers discussion thread with subject “Transactions
involving multiple postgres foreign servers”
•
First WIP patch on 17th
Feb.
– 2015-06 commitfest
– Had several TODOs
•
Improved patch to be submitted soon
– Takes care of many TODOs
– Addresses atomic commit
– Does not address atomic visibility
Current status
Atomicity for transactions involving foreign server in PostgreSQL

More Related Content

Similar to Atomicity for transactions involving foreign server in PostgreSQL

Enhanced Live Migration for Intensive Memory Loads
Enhanced Live Migration for Intensive Memory LoadsEnhanced Live Migration for Intensive Memory Loads
Enhanced Live Migration for Intensive Memory LoadsSamsung Open Source Group
 
Application High Availability and Upgrades Using Oracle GoldenGate
Application High Availability and Upgrades Using Oracle GoldenGateApplication High Availability and Upgrades Using Oracle GoldenGate
Application High Availability and Upgrades Using Oracle GoldenGateShane Borden
 
GeeCon- 'www.NoSQL.com' by Mark Addy
GeeCon- 'www.NoSQL.com' by Mark Addy GeeCon- 'www.NoSQL.com' by Mark Addy
GeeCon- 'www.NoSQL.com' by Mark Addy C2B2 Consulting
 
Migrating to XtraDB Cluster
Migrating to XtraDB ClusterMigrating to XtraDB Cluster
Migrating to XtraDB Clusterpercona2013
 
2007-05-23 Cecchet_PGCon2007.ppt
2007-05-23 Cecchet_PGCon2007.ppt2007-05-23 Cecchet_PGCon2007.ppt
2007-05-23 Cecchet_PGCon2007.pptnadirpervez2
 
Taming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using TelegrafTaming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using TelegrafInfluxData
 
Migrating to XtraDB Cluster
Migrating to XtraDB ClusterMigrating to XtraDB Cluster
Migrating to XtraDB Clusterpercona2013
 
Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)Valerii Kravchuk
 
Percona Xtradb Cluster (pxc) 101 percona university 2019
Percona Xtradb Cluster (pxc) 101 percona university 2019Percona Xtradb Cluster (pxc) 101 percona university 2019
Percona Xtradb Cluster (pxc) 101 percona university 2019Marcelo Henrique Gonçalves
 
XPDS16: Live Migration of vGPU - Xiao Zheng, Intel Asia-Pacific Research & De...
XPDS16: Live Migration of vGPU - Xiao Zheng, Intel Asia-Pacific Research & De...XPDS16: Live Migration of vGPU - Xiao Zheng, Intel Asia-Pacific Research & De...
XPDS16: Live Migration of vGPU - Xiao Zheng, Intel Asia-Pacific Research & De...The Linux Foundation
 
7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwoashish61_scs
 
7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwoashish61_scs
 
IOUG Data Integration SIG w/ Oracle GoldenGate Solutions and Configuration
IOUG Data Integration SIG w/ Oracle GoldenGate Solutions and ConfigurationIOUG Data Integration SIG w/ Oracle GoldenGate Solutions and Configuration
IOUG Data Integration SIG w/ Oracle GoldenGate Solutions and ConfigurationBobby Curtis
 
Database , 13 Replication
Database , 13 ReplicationDatabase , 13 Replication
Database , 13 ReplicationAli Usman
 
Kapacitor Stream Processing
Kapacitor Stream ProcessingKapacitor Stream Processing
Kapacitor Stream ProcessingInfluxData
 
OpenZFS send and receive
OpenZFS send and receiveOpenZFS send and receive
OpenZFS send and receiveMatthew Ahrens
 
Ganeti Hands-on Walk-thru (part 2) -- LinuxCon 2012
Ganeti Hands-on Walk-thru (part 2) -- LinuxCon 2012Ganeti Hands-on Walk-thru (part 2) -- LinuxCon 2012
Ganeti Hands-on Walk-thru (part 2) -- LinuxCon 2012Lance Albertson
 
High-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQLHigh-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQLFromDual GmbH
 

Similar to Atomicity for transactions involving foreign server in PostgreSQL (20)

Enhanced Live Migration for Intensive Memory Loads
Enhanced Live Migration for Intensive Memory LoadsEnhanced Live Migration for Intensive Memory Loads
Enhanced Live Migration for Intensive Memory Loads
 
Application High Availability and Upgrades Using Oracle GoldenGate
Application High Availability and Upgrades Using Oracle GoldenGateApplication High Availability and Upgrades Using Oracle GoldenGate
Application High Availability and Upgrades Using Oracle GoldenGate
 
GeeCon- 'www.NoSQL.com' by Mark Addy
GeeCon- 'www.NoSQL.com' by Mark Addy GeeCon- 'www.NoSQL.com' by Mark Addy
GeeCon- 'www.NoSQL.com' by Mark Addy
 
Migrating to XtraDB Cluster
Migrating to XtraDB ClusterMigrating to XtraDB Cluster
Migrating to XtraDB Cluster
 
2007-05-23 Cecchet_PGCon2007.ppt
2007-05-23 Cecchet_PGCon2007.ppt2007-05-23 Cecchet_PGCon2007.ppt
2007-05-23 Cecchet_PGCon2007.ppt
 
Taming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using TelegrafTaming the Tiger: Tips and Tricks for Using Telegraf
Taming the Tiger: Tips and Tricks for Using Telegraf
 
Migrating to XtraDB Cluster
Migrating to XtraDB ClusterMigrating to XtraDB Cluster
Migrating to XtraDB Cluster
 
Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)
 
Percona Xtradb Cluster (pxc) 101 percona university 2019
Percona Xtradb Cluster (pxc) 101 percona university 2019Percona Xtradb Cluster (pxc) 101 percona university 2019
Percona Xtradb Cluster (pxc) 101 percona university 2019
 
XPDS16: Live Migration of vGPU - Xiao Zheng, Intel Asia-Pacific Research & De...
XPDS16: Live Migration of vGPU - Xiao Zheng, Intel Asia-Pacific Research & De...XPDS16: Live Migration of vGPU - Xiao Zheng, Intel Asia-Pacific Research & De...
XPDS16: Live Migration of vGPU - Xiao Zheng, Intel Asia-Pacific Research & De...
 
7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwo
 
7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwo
 
IOUG Data Integration SIG w/ Oracle GoldenGate Solutions and Configuration
IOUG Data Integration SIG w/ Oracle GoldenGate Solutions and ConfigurationIOUG Data Integration SIG w/ Oracle GoldenGate Solutions and Configuration
IOUG Data Integration SIG w/ Oracle GoldenGate Solutions and Configuration
 
Database , 13 Replication
Database , 13 ReplicationDatabase , 13 Replication
Database , 13 Replication
 
OpenDataPlane Project
OpenDataPlane ProjectOpenDataPlane Project
OpenDataPlane Project
 
Kapacitor Stream Processing
Kapacitor Stream ProcessingKapacitor Stream Processing
Kapacitor Stream Processing
 
OpenZFS send and receive
OpenZFS send and receiveOpenZFS send and receive
OpenZFS send and receive
 
Ganeti Hands-on Walk-thru (part 2) -- LinuxCon 2012
Ganeti Hands-on Walk-thru (part 2) -- LinuxCon 2012Ganeti Hands-on Walk-thru (part 2) -- LinuxCon 2012
Ganeti Hands-on Walk-thru (part 2) -- LinuxCon 2012
 
Distributed fun with etcd
Distributed fun with etcdDistributed fun with etcd
Distributed fun with etcd
 
High-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQLHigh-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQL
 

Recently uploaded

Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...amitlee9823
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
➥🔝 7737669865 🔝▻ Dindigul Call-girls in Women Seeking Men 🔝Dindigul🔝 Escor...
➥🔝 7737669865 🔝▻ Dindigul Call-girls in Women Seeking Men  🔝Dindigul🔝   Escor...➥🔝 7737669865 🔝▻ Dindigul Call-girls in Women Seeking Men  🔝Dindigul🔝   Escor...
➥🔝 7737669865 🔝▻ Dindigul Call-girls in Women Seeking Men 🔝Dindigul🔝 Escor...amitlee9823
 
Detecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning ApproachDetecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning ApproachBoston Institute of Analytics
 
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...amitlee9823
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...karishmasinghjnh
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...Elaine Werffeli
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteedamy56318795
 
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...gajnagarg
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Just Call Vip call girls Bellary Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls Bellary Escorts ☎️9352988975 Two shot with one girl ...Just Call Vip call girls Bellary Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls Bellary Escorts ☎️9352988975 Two shot with one girl ...gajnagarg
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraGovindSinghDasila
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...amitlee9823
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...amitlee9823
 

Recently uploaded (20)

Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
➥🔝 7737669865 🔝▻ Dindigul Call-girls in Women Seeking Men 🔝Dindigul🔝 Escor...
➥🔝 7737669865 🔝▻ Dindigul Call-girls in Women Seeking Men  🔝Dindigul🔝   Escor...➥🔝 7737669865 🔝▻ Dindigul Call-girls in Women Seeking Men  🔝Dindigul🔝   Escor...
➥🔝 7737669865 🔝▻ Dindigul Call-girls in Women Seeking Men 🔝Dindigul🔝 Escor...
 
Detecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning ApproachDetecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning Approach
 
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
 
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
👉 Amritsar Call Girl 👉📞 6367187148 👉📞 Just📲 Call Ruhi Call Girl Phone No Amri...
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Just Call Vip call girls Bellary Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls Bellary Escorts ☎️9352988975 Two shot with one girl ...Just Call Vip call girls Bellary Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls Bellary Escorts ☎️9352988975 Two shot with one girl ...
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - Almora
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men  🔝Mathura🔝   Escorts...
➥🔝 7737669865 🔝▻ Mathura Call-girls in Women Seeking Men 🔝Mathura🔝 Escorts...
 
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
 

Atomicity for transactions involving foreign server in PostgreSQL

  • 1. © 2013 EDB All rights reserved. 1 Atomicity for transactions involving foreign servers • Ashutosh Bapat | 19th June 2015 @PGCon 2015, Ottawa, Canada
  • 2. © 2013 EDB All rights reserved. 2 • Atomic commit for transactions involving foreign servers – Current status – Solution – two-phase commit protocol – Overview of implementation – Foreign servers without 2PC support • Atomic visibility Agenda
  • 3. © 2013 EDB All rights reserved. 3 Atomicity val 1 2 tab1 val 1 2 tab2 BEGIN; UPDATE tab1 SET val = val + 1; UPDATE tab2 SET val = val + 2; COMMIT; val 1 2 tab1 val 1 2 tab2 val 2 3 tab1 val 3 4 tab2 success val 2 3 tab1 val 1 2 tab2 failure
  • 4. © 2013 EDB All rights reserved. 4 Distributed Atomicity val 1 2 tab1 val 1 2 tab2 BEGIN; UPDATE tab1 SET val = val + 1; UPDATE tab2 SET val = val + 2; COMMIT; val 1 2 tab1 val 1 2 tab2 val 2 3 tab1 val 3 4 tab2 val 2 3 tab1 val 1 2 tab2 Coordinator FS 1 FS 2 FDW FDW failure success
  • 5. © 2013 EDB All rights reserved. 5 Atomicity - foreign table inheritance val 1 2 chld1 val 1 2 chld2 UPDATE parent SET val = val + 1; val 1 2 tab1 val 1 2 tab2 val 2 3 tab1 val 2 3 tab2 val 2 3 tab1 val 1 2 tab2 Coordinator FS 1 FS 2 FDW FDW failure success parent
  • 6. © 2013 EDB All rights reserved. 6 • Transaction management is entirely implemented by FDW – postgres_fdw uses one-phase commit – any failure (including connectivity) during commit processing can cause changes to some foreign servers committed and others aborted • Atomicity is not guaranteed Current status
  • 7. © 2013 EDB All rights reserved. 7 Two-phase commit Prepare transaction on foreign server Prepare succeeded? Next foreign server? yes yes Commit all prepared transactions. No Abort all prepared transactions Abort any unprepared transactions No Phase 1 Phase 2 failure Commit processing, record commit locally Local pre-commit processing
  • 8. © 2013 EDB All rights reserved. 8 Two-phase commit Prepare transaction on foreign server Prepare succeeded? Next foreign server? yes yes Commit all prepared transactions. No Abort all prepared transactions Abort any unprepared transactions No Phase 1 Phase 2 Connectivity failure, coordinator/foreign server crash • all the foreign transactions and local transaction may not commit at the same time – Atomic commit – guaranteed – Atomic visibility – not guaranteed • Unresolved prepared transactions – prepared transactions waiting to be committed/aborted – Blocked resources, degraded performance
  • 9. © 2013 EDB All rights reserved. 9 Remembering foreign transactions Log about prepared transactions Persist prepared transaction information to disk Prepare transaction on foreign server Get prepared transaction information pg_fdw_xact/ XLOG In-memory array Crash recovery, replication Server restarts Prepare transaction on foreign server
  • 10. © 2013 EDB All rights reserved. 10 Resolving foreign transactions Log the removal of foreign transaction information Remove foreign transaction from the disk Commit/Abort foreign transaction pg_fdw_xact/ XLOG In-memory array Crash recovery, replication Commit/abort foreign transaction Successful? Yes No Retried by resolver till resolved
  • 11. © 2013 EDB All rights reserved. 11 • Transaction id: decides the fate of foreign transaction • Database id: where to look for foreign server and user mapping • Foreign server and user: where and who prepared the foreign transaction • Foreign transaction id: identifies the prepared transaction on the foreign server – e.g. GID on PostgreSQL Foreign transaction information
  • 12. © 2013 EDB All rights reserved. 12 Foreign servers without 2PC support Commit transaction on foreign server Successful? Next foreign server? No No Yes Yes Transaction aborted on foreign server Local commit successful? Yes Abort transaction on all foreign servers No Commit transaction on foreign server Successful? Next foreign server? No No Yes Yes Precommit processing successful? Yes Abort transaction on all remaining foreign servers No Vs
  • 13. © 2013 EDB All rights reserved. 13 • GetPrepareId – function to obtain prepared transaction id for a given foreign server – Each FDW might have different rules for identifier – Persisted and WAL logged FDW hooks for transaction management
  • 14. © 2013 EDB All rights reserved. 14 • HandleForeignTransaction - function to end foreign transaction in following ways – Commit/Rollback running transaction – Prepare running transaction – Commit/Rollback prepared transaction with given identifier FDW hooks for transaction management
  • 15. © 2013 EDB All rights reserved. 15 • atomic_foreign_transaction – when ON, two phase commit is used for transactions involving foreign servers. – When ON requires all participating servers to support 2PC – Can be set any time during the transaction.Value at the time of commit is used. • max_foreign_xacts – maximum number of transactions prepared on foreign servers at a given time GUCs
  • 16. © 2013 EDB All rights reserved. 16 • Builtin function (pg_fdw_resolve())– resolves all the unresolved foreign transactions in the database where it's run • Background worker process – fires the built-in function by connecting to various databases – Available at contrib/pg_fdw_xact_resolver – Install and add to 'shared_preload_libraries' (and restart) Foreign transaction resolver
  • 17. © 2013 EDB All rights reserved. 17 Atomic visibility
  • 18. © 2013 EDB All rights reserved. 18 • Problem: MVCC allows older versions to be read – Older version of data is read while transaction modifying it is prepared but not committed/resolved • Solution: Wait for prepared transactions to get committed/resolved – Stronger locking – FOR SHARE, SERIALISABLE ISOLATION – performance affected – Resolve prepared transactions before data is accessed ● You have connectivity now, right? ● How to detect this situation? Atomic visibility – rough ideas
  • 19. © 2013 EDB All rights reserved. 19 • Hackers discussion thread with subject “Transactions involving multiple postgres foreign servers” • First WIP patch on 17th Feb. – 2015-06 commitfest – Had several TODOs • Improved patch to be submitted soon – Takes care of many TODOs – Addresses atomic commit – Does not address atomic visibility Current status