-
Notifications
You must be signed in to change notification settings - Fork 816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multihost - replica mode #5177
Comments
I'm not sure it's even possible for us to implement that. From my understanding the main difference between synchronous and asynchronous replication is that while synchronous sends the data the moment a transaction is commited, asynchronous tends to aggregate and send it in batches depending on replication delay. The point is, standby isn't aware whether it's a synchronous or asynchronous replica, so we also can't determine that. |
Okay, if i have this information in my side, how to effective way to open connection? It is okay if i have NpgsqlDatataSource and will be create connection with new NpgsqlConnection("User ID=postgres;Password=docker;Host=sync-replica-host;Port=5432;Database=postgres;Pooling=true;LoadTableComposites=true") Will there be problems with the efficiency of the pool? |
How about having multiple NpgsqlDataSources (Pools)? |
Maybe I'm wrong, but I saw an issue where they said that keeping several pools is inefficient, so they made a MultihostDataSource |
Essentially a DataSource is a pool. |
Okay, thanks a lot |
BTW: If you end up using multiple DataSources and use dependency injection, you may be interested in following #5134. |
Now we have target session attributes and we can choose betwen master and replica, but how i can choose only sync or only async replica?
var conn = await (_npgsqlDataSource).OpenConnectionAsync(TargetSessionAttributes.Standby, token);
conn.Host => 10.41.64.64
`patronictl list
| Member | Host | Role | State | TL | Lag in MB |
+-----------------------------------------+-------------+--------------+---------+-----+-----------+
| devpostgres9b48x69d-1452z1.com | 10.41.72.37 | Leader | running | 206 | |
| devpostgres9b48x69d-1463z1.com | 10.41.64.64 | Replica | running | 206 | 0 |
| devpostgres9b48x69d-1464z1.com | 10.41.60.35 | Sync Standby | running | 206 | 0 |
| devpostgres9b48x69d-1541z1.com | 10.41.80.36 | Sync Standby | running | 206 | 0 |
+-----------------------------------------+-------------+--------------+---------+-----+-----------+
`
in conn.Host property we received async replica ip address instead of sync, what am I doing wrong?
Npgsql version: 7.0.4
PostgreSQL version:
Operating system:
The text was updated successfully, but these errors were encountered: