Endpoints that don't do database access shouldn't have UnitOfWork annotation
See original GitHub issueFeature Request
The @UnitOfWork
annotation should only be present on endpoints whose implementations access the database.
When present, the annotation starts a database transaction, which requires a database connection. When contention for database pool connections gets tight (there are 32 available connections), this can slow down the endpoints, cause them to fail (if unable to get a connection soon enough), and/or also the same effect on other endpoints that do require a connection.
Off-hand, noticed 3 endpoints in MetadataResource that have but do not need the annotation. There may be more – implementor should check.
- getSourceControlList
- getDockerRegistries
- getDescriptorLanguages
┆Issue is synchronized with this Jira Story ┆Fix Versions: Dockstore 1.7 ┆Issue Number: DOCK-628 ┆Sprint: Seabright Sprint 7 Gondola ┆Issue Type: Story
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top GitHub Comments
The UnitOfWork annotation can be used “non-transactionally” by setting
transactional
to false for things that won’t need to be rolled back.Similarly, when an item is read only or if you want to set a different cache mode, it can be done using parameters to the annotation. I believe there is an advantage to keeping the annotation so that Hibernate can handle caching even for resources that don’t require a write transaction.
For example,
metadata/sourceControlList
does not “need” a hibernate session in that it doesn’t touch the DB. However, other endpoints that don’t perform write transactions should probably get theread-only
tag to answer @denis-yuen .https://www.dropwizard.io/0.7.1/dropwizard-hibernate/apidocs/io/dropwizard/hibernate/UnitOfWork.html
On the other hand, this isn’t really user-visible.