Is there’s a way to auto-discover the current leader of YB-master machine? Or can we proxy the ysql requests from follower to leader?
From my side, if I don’t connect with the leader of yb-master, the client will throw the exception:
psql: error: FATAL: Timed out: OpenTable RPC (request call id 3) to 10.4.x.x:9100 timed out after 120.000s
There are multiple things to say here.
The message you are getting indicates an error in your setup.
The architecture of YugabyteDB YSQL is that every tablet server (tserver) spawns an instance of YSQL, which is our port of PostgreSQL modified to run with the YugabyteDB DocDB storage services. DocDB storage services consists of a cluster of master and tablet server nodes.
Every YSQL instance uses its local tablet server instance to communicate, which routes the requests inside the cluster, and proxies the requests. Every YSQL instance should be able to communicate with the cluster services, unless there is something not functioning correctly.
When a YSQL client connects to any of the YSQL instances, it builds a socalled ‘backend’ process in the YSQL server, which needs to perform some initial work to function, which requires to load some “catalog” data, which is metadata about the database it connected to. That catalog data is located in he master, and is queried from the master leader. All user data will be stored on the tablet servers.
Getting back to your error: hopefully it’s clear that when you get an error creating a connection indicating it cannot open a table (OpenTable RPC), you are not connecting to the wrong node, but there is an error in the setup. Port 9100 is the default RPC port of the tablet server.
Maybe the tablet servers cannot talk to each other over RPC (port 9100 by default).