Skip to content

InternalConnectorRegistry.executor uses non-daemon threads #617

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

Closed
ukarlsson opened this issue Feb 21, 2025 · 2 comments · Fixed by #618 or #619
Closed

InternalConnectorRegistry.executor uses non-daemon threads #617

ukarlsson opened this issue Feb 21, 2025 · 2 comments · Fixed by #618 or #619
Assignees
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@ukarlsson
Copy link

Bug Description

For InternalConnectorRegistry.executor, it uses non-daemon threads which prevents normal shutdown of our application. It is very easy to reproduce this for us - whenever we have a command that connects to AlloyDB it does not terminate when the main function exits, and we instead need to put System.exit(0) or ConnectorRegistry.shutdown() at the end of the main function.

It seems like even error on the main thread does not terminate the process now with the connector, so we have batch jobs that fail and linger in this zombie state.

In order to create daemon threads, creation of executors should be changed to something like

this.executor = MoreExecutors.listeningDecorator(
    Executors.newScheduledThreadPool(8, r -> {
        Thread t = new Thread(r);
        t.setDaemon(true);
        return t;
    })
);

Many thanks for looking into this

Example code (or command)

Stacktrace

Steps to reproduce?

  1. ?
  2. ?
  3. ?
    ...

Environment

  1. OS type and version:
  2. Java SDK version:
  3. AlloyDB Java Connector version:

Additional Details

No response

@ukarlsson ukarlsson added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Feb 21, 2025
@enocom enocom added the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label Feb 21, 2025
@enocom
Copy link
Member

enocom commented Feb 21, 2025

Thanks for the report, @ukarlsson. This is an oversight and we'll get it fixed promptly.

enocom added a commit that referenced this issue Feb 21, 2025
Without using daemon threads, the Connector will prevent a calling
process from exiting cleanly.

Fixes #617
@enocom enocom closed this as completed in 6defeb3 Feb 21, 2025
@enocom
Copy link
Member

enocom commented Feb 26, 2025

This is fixed in v1.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
2 participants