citusdata / pg_shard

ATTENTION: pg_shard is superseded by Citus, its more powerful replacement
https://github.com/citusdata/citus
GNU Lesser General Public License v3.0
1.06k stars 63 forks source link

Transaction manager integration #147

Closed kelvich closed 8 years ago

kelvich commented 8 years ago

We slightly changed DTM interface and now it should be called in following way:

SELECT dtm_begin_transaction(); -- Run on node1, returns int, for example 42
SELECT dtm_join_transaction(42); -- Run on node2
-- Now we can start usual transactions, snapshot will be set automatically for both nodes.
(COMMIT; COMMIT) -- commit as usual should be done in parallel

Also I've added PrepareDtmTransaction to distributed selects too, so now we can have consistent read transactions too.

marcocitus commented 8 years ago

That's a great improvement over the previous API! Does the dtm_begin_transaction need to be in the same transaction block, or does it just call the DTMD? For example, if the coordinator had the DTM extension installed, could it call dtm_begin_transaction locally?

kelvich commented 8 years ago

dtm_begin_transaction should be called before transaction and on the node where that transaction will take place. So no, you can't call it on master but perform transaction on different node.

What we have now with global selects -- it's our banking test. When pg_shard.use_dtm_transactions is on we see only one value of total amount of money on accounts, and when pg_shard.use_dtm_transactions is off total amount frequently fluctuates during concurrent updates.

jasonmp85 commented 8 years ago

This is neat, but is it actually intended for merging, or just part of a proof-of-concept I'm not privy to?

Notably:

jasonmp85 commented 8 years ago

Oh, I completely missed that the target for this PR is not develop. Carry on!