good morning!!!!

Skip to content
Snippets Groups Projects
Commit 4a9fb33a authored by Garet Halliday's avatar Garet Halliday
Browse files

fix panic if no primary server

parent 5243d36f
No related branches found
No related tags found
No related merge requests found
...@@ -111,6 +111,8 @@ func (c *ConnectionPool) chooseServer(query string) *servers { ...@@ -111,6 +111,8 @@ func (c *ConnectionPool) chooseServer(query string) *servers {
} }
} }
// there are no servers available in the pool, let's make a new connection
// connect to primary server // connect to primary server
// TODO primary server might not be 0, could have no primary server so should fall back to server with role None // TODO primary server might not be 0, could have no primary server so should fall back to server with role None
primary, err := server.Dial(context.Background(), fmt.Sprintf("%s:%d", s.conf.Servers[0].Host(), s.conf.Servers[0].Port()), c.user, s.conf.Database, nil) primary, err := server.Dial(context.Background(), fmt.Sprintf("%s:%d", s.conf.Servers[0].Host(), s.conf.Servers[0].Port()), c.user, s.conf.Database, nil)
...@@ -156,10 +158,10 @@ func (c *ConnectionPool) GetUser() *config.User { ...@@ -156,10 +158,10 @@ func (c *ConnectionPool) GetUser() *config.User {
func (c *ConnectionPool) GetServerInfo() []*protocol.ParameterStatus { func (c *ConnectionPool) GetServerInfo() []*protocol.ParameterStatus {
srv := c.chooseServer("") srv := c.chooseServer("")
defer srv.mu.Unlock()
if srv == nil { if srv == nil {
return nil return nil
} }
defer srv.mu.Unlock()
return srv.primary.GetServerInfo() return srv.primary.GetServerInfo()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment