Skip to content

Commit

Permalink
ERM-3455: pushPkg endpoint in mod-agreements works unexpectedly slowly (
Browse files Browse the repository at this point in the history
#839)

* perf: pushPkg endpoint in mod-agreements works unexpectedly slowly

Impropve transaction handling in a couple of key areas to facilitate pushPkg functionality -- matches changes made in ingest process and for pushPCI previously

ERM-3455

* fix: Remove special Org transaction handling as it causes int tests to crash (Perf seems to be fine enough without it)

* fix: Reinstated flushes in coordinateOrg, turns out they were necessary
  • Loading branch information
EthanFreestone authored Nov 28, 2024
1 parent 6359462 commit a8fc66f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ public class DependentModuleProxyService {
OkapiClient okapiClient

public Org coordinateOrg(String orgName) {

// Simply call the verb method on the client (get, post, put, delete). The client itself should take care of everything else.
// Get and Delete take the uri with optional params map for the query string.
// Post, Put and Patch take in the uri, data that can be converted to json (String or map) and optional params map for the query string.
Org org = Org.findByName(orgName)
Org org = Org.findByName(orgName) // This cannot be swapped for executeQuery SELECT -- possibly due to the bindUsingWhenRef

if (!org) {
log.debug "No local org for ${orgName}. Check vendors."
Expand All @@ -51,7 +50,7 @@ public class DependentModuleProxyService {
"first" : 0,
"last" : 0
}
*/
*/

switch (mod_vendor_lookup_result.total_records) {
case 1:
Expand All @@ -62,7 +61,7 @@ public class DependentModuleProxyService {
name: result.name,
orgsUuid: result.id,
sourceURI: "/vendor/${result.id}"
).save( flush:true, failOnError:true )
).save( flush: true, failOnError:true )
break

case 0:
Expand All @@ -74,7 +73,7 @@ public class DependentModuleProxyService {

// Create a new local one.
log.debug "No vendor found. Adding local org for ${orgName}"
org = (new Org(name:orgName)).save(flush:true, failOnError:true)
org = (new Org(name:orgName)).save( flush: true, failOnError:true )
break

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,26 @@ class PushKBService implements DataBinder {
if (utilityService.checkValidBinding(package_data)) {

// Start a transaction -- method in packageIngestService needs this
Pkg.withNewTransaction { status ->
// Farm out package lookup and creation to a separate method

// These calls mirror what's in upsertPackage but conveniently avoid the
// logic which handles TIPPS
Pkg pkg = packageIngestService.lookupOrCreatePkg(package_data);
// Retain logging information
MDC.put('packageSource', pkg.source.toString())
MDC.put('packageReference', pkg.reference.toString())

// Update identifiers from citation
identifierService.updatePackageIdentifiers(pkg, package_data.identifiers)
Pkg.withSession { currentSess ->
Pkg.withTransaction {
Pkg.withNewSession { newSess ->
Pkg.withTransaction {
// Farm out package lookup and creation to a separate method

// These calls mirror what's in upsertPackage but conveniently avoid the
// logic which handles TIPPS
Pkg pkg = packageIngestService.lookupOrCreatePkg(package_data);
// Retain logging information
MDC.put('packageSource', pkg.source.toString())
MDC.put('packageReference', pkg.reference.toString())

// Update identifiers from citation
identifierService.updatePackageIdentifiers(pkg, package_data.identifiers)
}
newSess.clear()
}
}
}

}
}
result.success = true
Expand Down

0 comments on commit a8fc66f

Please sign in to comment.