Skip to content
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

Bug: redundant GremlinServers will be opened when use cluster #19

Open
vayneYang opened this issue Dec 27, 2019 · 0 comments · May be fixed by #20
Open

Bug: redundant GremlinServers will be opened when use cluster #19

vayneYang opened this issue Dec 27, 2019 · 0 comments · May be fixed by #20

Comments

@vayneYang
Copy link

Hello! I found a bug in driver/cluster.py, which happend when using coroutines to send requests to gremlin-server. The impact is that redundant GremlinServers and its hosts will be established.

    async def get_connection(self, hostname=None):
        """
        **coroutine** Get connection from next available host in a round robin
        fashion.

        :returns: :py:class:`Connection<aiogremlin.driver.connection.Connection>`
        """
        if not self._hosts:
            await self.establish_hosts()
        if hostname:
            try:
                host = self._hostmap[hostname]
            except KeyError:
                raise exception.ConfigError(
                    'Unknown host: {}'.format(hostname))
        else:
            host = self._hosts.popleft()
        conn = await host.get_connection()
        self._hosts.append(host) 
        return conn

When self._hosts.popleft(), the variable host could be empty, which lead to other coroutines found that not self._hosts is True and establish a new one. Moving self._hosts.append(host) ahead of conn = await host.get_connection() can fix it.

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 a pull request may close this issue.

1 participant