Skip to content

Support for connection load balancing across read-replica cluster nodes#6

Merged
Sfurti-yb merged 9 commits into
8.0.3-yb-1from
RR-support
Nov 14, 2024
Merged

Support for connection load balancing across read-replica cluster nodes#6
Sfurti-yb merged 9 commits into
8.0.3-yb-1from
RR-support

Conversation

@Sfurti-yb
Copy link
Copy Markdown
Collaborator

@Sfurti-yb Sfurti-yb commented Sep 17, 2024

Why

  • Currently, the smart driver does not distinguish between primary nodes and read-replica nodes while distributing the connections.
  • Such a mechanism is required when client wants to have one app talk to read-replica nodes only while another one communicates with primary cluster
  • The IDEA ticket

What

  • Here is the doc which provides the details about the design.

Testing

  • Added test cases in repository itself.

Copy link
Copy Markdown
Collaborator

@ashetkar ashetkar left a comment

Choose a reason for hiding this comment

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

First pass

Comment thread src/Npgsql/ClusterAwareDataSource.cs Outdated
Comment thread src/Npgsql/ClusterAwareDataSource.cs Outdated
/// <summary>
/// TODO
/// </summary>
protected static Dictionary<NpgsqlDataSource, int> poolToNumConnMapRR = new Dictionary<NpgsqlDataSource, int>();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Something to ponder over: Can we simply use the size of the datasource/pool?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is possible but would require a lot of rework of all the methods and logic. I can file a ticket for this.

Comment thread src/Npgsql/ClusterAwareDataSource.cs
Comment thread src/Npgsql/ClusterAwareDataSource.cs Outdated
Comment thread src/Npgsql/ClusterAwareDataSource.cs Outdated
Comment thread src/Npgsql/ClusterAwareDataSource.cs Outdated
Comment thread src/Npgsql/ClusterAwareDataSource.cs Outdated
Comment thread src/Npgsql/ClusterAwareDataSource.cs Outdated
Comment thread src/Npgsql/ClusterAwareDataSource.cs Outdated
Comment thread test/Npgsql.Tests/MultipleHostsTests.cs Outdated
Comment thread test/Npgsql.Tests/YBClusterAwareRRSupportTests.cs Outdated
Comment thread test/Npgsql.Tests/YBClusterAwareRRSupportTests.cs
Comment thread test/Npgsql.Tests/YBTopologyAwareRRSupportTests.cs
Comment thread test/Npgsql.Tests/YBTopologyAwareRRSupportTests.cs
Comment thread src/Npgsql/NpgsqlMultiHostDataSource.cs
@Sfurti-yb Sfurti-yb merged commit 9409158 into 8.0.3-yb-1 Nov 14, 2024
@ashetkar ashetkar deleted the RR-support branch February 6, 2025 05:06
Sfurti-yb added a commit that referenced this pull request Feb 26, 2025
…es (#6)

* Initial changes to ClusterAwareLoadBalancer for RR support

* Initial changes for RR support

* Test cleanup

* Addressed the review comments

* Modified tests to include client side verification + Check if connections are closed properly

* Make GetLoad static

* Changes as per review comments

* Refactored the tests to add method call in place of code repititions

* Format the new code
Sfurti-yb added a commit that referenced this pull request Sep 25, 2025
* Upgrading the version from 8.0.0 to 8.0.3 (#4)

* First draft for the smart feature

* TopologyAwareDataSource Code

* Adding Refresh Interval + Changes in Fallback toology

* Fallback tests + minor improvements

* Review comments + Multiple host in URL

* Minor changes to refresh

* Review comments

* Improved the tests + updated the README

* MultiThreading bug fix

* Review Comments

* Fallback Test cases + fallback topology fix

* Change namespace from Npgsql to YBNpgsql

* Changing the version + Assembly name

* Renaming namespace in new files

* Renaming namespace in few more files

* Preparing for release

* Fix for the fallback issue

* Resolved some build issues

* Added the flags for supression of sqls

* Change support of Unlisten and Advisory Locks to false

* Changed the method for retrieving of allowed placement values

* Removed local package source from Nuget.config + Added the new connection properties to Readme

---------

Co-authored-by: Sfurti Sarah <ssarah@Aadhas-MacBook-Pro.local>
Co-authored-by: Amogh Shetkar <ashetkar@yugabyte.com>

* Added More Log statements

* Changed PackageIDs and AssemblyName for Nuget publish (#5)

* Changed PackageIDs and AssemblyName for Nuget publish

* Updated the README files

* Support for connection load balancing across read-replica cluster nodes (#6)

* Initial changes to ClusterAwareLoadBalancer for RR support

* Initial changes for RR support

* Test cleanup

* Addressed the review comments

* Modified tests to include client side verification + Check if connections are closed properly

* Make GetLoad static

* Changes as per review comments

* Refactored the tests to add method call in place of code repititions

* Format the new code

* Updated some tests to include higher timeout and updated method signature for hasbetternodeavailable method

* Updating version number and Readme for release

* Resolve build issues

* Added fix for NoHostSuitableException in case of External Load Balancer + Fix for better node availability

* Updated the test file

* Updated the driver version

---------

Co-authored-by: Sfurti Sarah <ssarah@Aadhas-MacBook-Pro.local>
Co-authored-by: Amogh Shetkar <ashetkar@yugabyte.com>
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