Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mdashti
Copy link
Contributor

@mdashti mdashti commented Sep 22, 2023

This is a preview for the transparent mode, which transparently supports distributed transactions (with two-phase commit).

The current PR is created for the purpose of getting your feedback.

The main missing element is the lack of tests in the PR, which will be added soon.

Please note that I've tried to move the PR-specific changes to client_xact.rs, server_xact.rs, and query_messages.rs, but it's natural for some of those functions to become a part of client.rs, server.rs and messages.rs respectively. This is especially true for the functions that can be methods of Client or Server.

Here's an example of how you can try this PR (using the default pgcat settings (i.e., pgcat.toml in the repo root):

Step 1: connect to pgcat:

PGPASSWORD="sharding_user" psql sharded_db -h 127.0.0.1 -p 6432 -U sharding_user

Step 2: Initialize your database:

set shard to '0'; drop table if exists test_tbl; 
set shard to '1'; drop table if exists test_tbl; 

set shard to '0'; create table test_tbl (n int); 
set shard to '1'; create table test_tbl (n int); 

set shard to '0'; insert into test_tbl values (2), (4);
set shard to '1'; insert into test_tbl values (1), (3);

Step 3: run a distributed transaction:

set shard to '0'; begin; select * from test_tbl where n >= 3;

-- implicitly begins a distributed transaction
set shard to '1'; select * from test_tbl where n >= 3;

-- commits the distributed transaction
commit;

src/server.rs Outdated
@@ -461,7 +461,15 @@ impl Server {
None => &user.username,
};

let password = user.server_password.as_ref();
#[allow(clippy::match_as_ref)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here comes the clippy overrides! Inevitable I guess, but that's why I avoided clippy for the longest time :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@levkk I agree, it's not pretty, but hopefully we'll have only a few of those.
In my experience, the only clippy override that's hard to avoid is #[allow(clippy::too_many_arguments)].

BTW, created #614 to remove these overrides.

@mdashti mdashti marked this pull request as draft October 11, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants