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

Managing Slick DB resources #172

Open
pjfanning opened this issue Jun 16, 2024 Discussed in #168 · 0 comments
Open

Managing Slick DB resources #172

pjfanning opened this issue Jun 16, 2024 Discussed in #168 · 0 comments

Comments

@pjfanning
Copy link
Contributor

Discussed in #168

Originally posted by pjfanning June 13, 2024
When you call databaseConfig.db, you are expected to close that db instance.

pekko-projection-slick has never bothered to do this.

It appears that pekko-projection-slick users create their own databaseConfig and it is left to them (at the moment) to know about and implement the databaseConfig.db.close() call. Have a look at SlickProjectionSpec to see how this test spec creates a databaseConfig and then in afterAll it calls databaseConfig.db.close()

If we were to take responsibility for closing the databaseConfig.db instances, there are some problems:

  • there is no lifecycle that we can rely on, we are probably left with adding a shutdown hook or something like that
  • There are a lot of functions in SlickProjection that call createOffsetStore and this createOffsetStore calls databaseConfig.db - potentially create a new db instance that needs managing. If you call databaseConfig.db more than once on the same databaseConfig instance, you should get the same db instance (they are lazily created and reused).

This is my opinion - I think we should not change anything and just document that users need to look after their own databaseConfig lifecycle.

@pjfanning pjfanning added this to the 1.1.0-M1 milestone Jul 12, 2024
@pjfanning pjfanning removed this from the 1.1.0-M1 milestone Aug 23, 2024
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

No branches or pull requests

1 participant