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

CORE-362: new DataSource.inTransaction signatures #3260

Merged
merged 11 commits into from
Apr 7, 2025

Conversation

davidangb
Copy link
Contributor

@davidangb davidangb commented Apr 4, 2025

Ticket: CORE-362

Some prefactoring for the main changes in CORE-362.

This PR adds new, hopefully more readable, signatures for the DataSource.inTransaction method. This includes a new ability to specify the result set concurrency: ReadOnly vs. Updatable. See https://dev.mysql.com/doc/refman/8.4/en/innodb-performance-ro-txn.html for more info on the ReadOnly hint.

See EntityStatisticsCacheMonitor and LocalEntityProvider for example changes of how these new signatures look. The TL;DR is it changes the code from

dataSource.inTransaction{ … many lines of code … }, ReadCommitted

to

dataSource.inTransaction(ReadCommitted){ … many lines of code … }

@@ -170,7 +170,7 @@ class BucketMigrationServiceImpl(val dataSource: SlickDataSource, val samDAO: Sa
// get migration progress if it exists
workspacesWithProgressOpt <- workspaces.traverse { workspace =>
dataSource
.inTransaction(getBucketMigrationProgress(workspace))
.inTransaction(dataAccess => getBucketMigrationProgress(workspace)(dataAccess))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previously-working function currying here needs to be explicit with the new inTransaction signatures.

@@ -69,7 +70,7 @@ class CoordinatedDataSourceActorSpec
val mockSlickDataSource = mock[SlickDataSource](RETURNS_SMART_NULLS)
val mockDataAccessFunction = mock[DataAccess => ReadWriteAction[Any]](RETURNS_SMART_NULLS)
val transactionIsolation = TransactionIsolation.RepeatableRead
when(mockSlickDataSource.inTransaction(mockDataAccessFunction, transactionIsolation))
when(mockSlickDataSource.inTransaction(argeq(mockDataAccessFunction), argeq(transactionIsolation), any()))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new signatures need updated mocks

@davidangb davidangb marked this pull request as ready for review April 4, 2025 18:57
@davidangb davidangb requested a review from a team as a code owner April 4, 2025 18:57
@davidangb davidangb requested review from dvoet and kevinmarete and removed request for a team April 4, 2025 18:57
Copy link
Contributor

@kevinmarete kevinmarete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice prefactor!

def batchUpdateEntities(entityUpdates: Seq[EntityUpdateDefinition], parentContext: RawlsRequestContext): Future[Traversable[Entity]]
def batchUpdateEntities(entityUpdates: Seq[EntityUpdateDefinition],
parentContext: RawlsRequestContext
): Future[Traversable[Entity]]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this PR has so much reformatting; this happened after rebasing #3249 into here.

* @tparam T type returned by the query
* @return query results
*/
// the `null` default for concurrency is ugly. However, it is the value specified by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could wrap it in an Option

@davidangb davidangb merged commit 4c59cad into develop Apr 7, 2025
29 checks passed
@davidangb davidangb deleted the da_CORE-362_inTransactionSignature branch April 7, 2025 14:08
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 this pull request may close these issues.

3 participants