question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Endpoints that don't do database access shouldn't have UnitOfWork annotation

See original GitHub issue

Feature 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
david4096commented, Apr 2, 2019

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 the read-only tag to answer @denis-yuen .

https://www.dropwizard.io/0.7.1/dropwizard-hibernate/apidocs/io/dropwizard/hibernate/UnitOfWork.html

0reactions
denis-yuencommented, Apr 10, 2019

On the other hand, this isn’t really user-visible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

An awesome guide on how to build RESTful APIs with ASP ...
Let's think in how the listing method should work. We need to access the database and return all categories, then we need to...
Read more >
Repository Pattern in ASP.NET Core - Ultimate Guide
A Repository pattern is a design pattern that mediates data from and to the Domain and Data Access Layers ( like Entity Framework...
Read more >
Avoid Wrapping DbContext in Using (and other gotchas) | Blog
I work with a lot of clients who are migrating from .NET Framework to .NET Core and .NET 5. Some of them weren't...
Read more >
Hibernate/Dropwizard: Find or create with @UnitOfWork does ...
When we added a database constraint that the itemId should be unique, we get a PSQL exception "duplicate key value violates unique constraint..."....
Read more >
Survey of Entity Framework Unit of Work Patterns - · Los Techies
A Unit of Work can consist of different types of operations such as Web Service calls, Database operations, or even in-memory operations, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found