Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e289726
Issue 52824: remove domain from cache if it's being updated
labkey-susanh May 16, 2025
0d89e53
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh May 22, 2025
fd3dea8
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh May 22, 2025
e96be00
fewer p's
labkey-susanh May 22, 2025
e9cc42f
If not for update, retrieve directly from the database.
labkey-susanh May 22, 2025
a5e4c3d
Mark as readOnly if from the cache.
labkey-susanh May 22, 2025
8ef82c9
Get domain for update when ensuring for UsersDomainKind
labkey-susanh May 23, 2025
b2044c5
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh May 23, 2025
d456974
More places to mark domains as for update or not
labkey-susanh May 23, 2025
afdab48
Get the mutable domain at the right time
labkey-susanh May 26, 2025
924a644
Merge from develop
labkey-susanh May 26, 2025
48678b5
Add forUpdate parameter to more methods
labkey-susanh May 26, 2025
68b1618
Add forUpdate parameter to more methods that are getting domains
labkey-susanh May 26, 2025
00faafe
get for update
labkey-susanh May 26, 2025
d3d31b3
More forUpdate parameters and make methods for data classes and sampl…
labkey-susanh May 26, 2025
1b03d59
get mutable domain during import
labkey-susanh May 27, 2025
4d41906
isForUpdate -> isMutable
labkey-susanh May 27, 2025
3519d58
Still more forUpdate parameters
labkey-susanh May 28, 2025
210a8ea
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh May 28, 2025
a6aca25
Use the forUpdate parameter
labkey-susanh May 28, 2025
17f1fa0
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh May 29, 2025
9342e55
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh Jun 2, 2025
bb2415a
Comments
labkey-susanh Jun 2, 2025
d4c11b4
Better handling of forUpdate and stashed objects
labkey-susanh Jun 2, 2025
2259fce
Merge remote-tracking branch 'origin/develop' into fb_getDomainForUpdate
labkey-susanh Jun 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions api/src/org/labkey/api/audit/AbstractAuditTypeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected AbstractAuditDomainKind getDomainKind()
public void initializeProvider(User user)
{
AbstractAuditDomainKind domainKind = getDomainKind();
Domain domain = getDomain();
Domain domain = getDomain(true);

// if the domain doesn't exist, create it
if (domain == null)
Expand Down Expand Up @@ -296,12 +296,17 @@ private void copyTo(DomainProperty dp, PropertyDescriptor pd, Container c)

@Override
public final Domain getDomain()
{
return getDomain(false);
}

protected Domain getDomain(boolean forUpdate)
{
DomainKind domainKind = getDomainKind();

String domainURI = domainKind.generateDomainURI(QUERY_SCHEMA_NAME, getEventName(), getDomainContainer(), null);

return PropertyService.get().getDomain(getDomainContainer(), domainURI);
return PropertyService.get().getDomain(getDomainContainer(), domainURI, forUpdate);
}


Expand Down
30 changes: 26 additions & 4 deletions api/src/org/labkey/api/exp/OntologyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2441,25 +2441,47 @@ public DomainDescriptor load(@NotNull Integer key, @Nullable Object argument)
}
}


public static DomainDescriptor getDomainDescriptor(int id)
{
return DOMAIN_DESC_BY_ID_CACHE.get(id);
return getDomainDescriptor(id, false);
}

public static DomainDescriptor getDomainDescriptor(int id, boolean forUpdate)
{
DomainDescriptor dd = DOMAIN_DESC_BY_ID_CACHE.get(id);
if (forUpdate)
Comment thread
labkey-susanh marked this conversation as resolved.
DOMAIN_DESC_BY_ID_CACHE.remove(id);
return dd;
}

@Nullable
public static DomainDescriptor getDomainDescriptor(String domainURI, Container c)
{
return getDomainDescriptor(domainURI, c, false);
}

@Nullable
public static DomainDescriptor getDomainDescriptor(String domainURI, Container c, boolean forUpdate)
{
if (c == null)
return null;

// cache lookup by project. if not found at project level, check to see if global
DomainDescriptor dd = DOMAIN_DESCRIPTORS_BY_URI_CACHE.get(getCacheKey(domainURI, c));
Pair<String, GUID> key = getCacheKey(domainURI, c);
DomainDescriptor dd = DOMAIN_DESCRIPTORS_BY_URI_CACHE.get(key);
if (null != dd)
{
if (forUpdate)
DOMAIN_DESCRIPTORS_BY_URI_CACHE.remove(key);
return dd;
}

// Try in the /Shared container too
return DOMAIN_DESCRIPTORS_BY_URI_CACHE.get(getCacheKey(domainURI, _sharedContainer));
key = getCacheKey(domainURI, _sharedContainer);
dd = DOMAIN_DESCRIPTORS_BY_URI_CACHE.get(key);
if (null != dd && forUpdate)
DOMAIN_DESCRIPTORS_BY_URI_CACHE.remove(key);
return dd;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion api/src/org/labkey/api/exp/property/DomainUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ public static ValidationException updateDomainDescriptor(GWTDomain<? extends GWT
LOG.info("Updating domain descriptor for " + orig.getName());
assert orig.getDomainURI().equals(update.getDomainURI());

Domain d = PropertyService.get().getDomain(container, update.getDomainURI());
// Issue 52824: when updating, remove domain descriptor from cache so others don't see a descriptor from the cache in a paritially updated state
Domain d = PropertyService.get().getDomain(container, update.getDomainURI(), true);
if (null == d)
{
ValidationException validationException = new ValidationException();
Expand Down
6 changes: 6 additions & 0 deletions api/src/org/labkey/api/exp/property/PropertyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ static void setInstance(PropertyService impl)
@Nullable
Domain getDomain(Container container, String domainURI);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe comments here about the default value too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.


@Nullable
Domain getDomain(Container container, String domainURI, boolean forUpdate);

@Nullable
Domain getDomain(int domainId);

@Nullable
Domain getDomain(int domainId, boolean forUpdate);

List<DomainKind<?>> getDomainKinds();

List<DomainKind<?>> getDomainKinds(Container container, User user, Set<String> domainKinds, boolean includeProjectAndShared);
Expand Down
2 changes: 1 addition & 1 deletion assay/api-src/org/labkey/api/assay/plate/PlateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static PlateService get()
/**
* Create the plate metadata domain for this container.
*/
@NotNull Domain ensurePlateMetadataDomain(Container container, User user) throws ValidationException;
@NotNull Domain ensurePlateMetadataDomain(Container container, User user, boolean forUpdate) throws ValidationException;

/**
* Name expressions for plate sets and plates.
Expand Down
4 changes: 2 additions & 2 deletions assay/src/org/labkey/assay/AssayUpgradeCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public static void deletePlateVocabDomains(ModuleContext ctx) throws Exception
{
// ensure the plate metadata domain for the top level biologics projects
if (container.isProject())
PlateManager.get().ensurePlateMetadataDomain(container, User.getAdminServiceUser());
PlateManager.get().ensurePlateMetadataDomain(container, User.getAdminServiceUser(), false);
biologicsFolders.add(container);
}
}
Expand Down Expand Up @@ -535,7 +535,7 @@ public static void renameWellMetadataFields(ModuleContext ctx) throws Exception
DbScope scope = AssayDbSchema.getInstance().getSchema().getScope();
for (Container container : metadataContainers)
{
Domain domain = PlateManager.get().getPlateMetadataDomain(container, User.getAdminServiceUser());
Domain domain = PlateManager.get().getPlateMetadataDomain(container, User.getAdminServiceUser(), true);
if (domain != null)
{
try (DbScope.Transaction tx = scope.ensureTransaction())
Expand Down
2 changes: 1 addition & 1 deletion assay/src/org/labkey/assay/PlateController.java
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ public static class EnsurePlateMetadataDomainAction extends MutatingApiAction<Ob
@Override
public Object execute(Object form, BindException errors) throws Exception
{
return success(PlateManager.get().ensurePlateMetadataDomain(getContainer(), getUser()).getTypeId());
return success(PlateManager.get().ensurePlateMetadataDomain(getContainer(), getUser(), false).getTypeId());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ public Map<String, List<GWTPropertyDescriptor>> previewFilterCriteriaColumns(@No
if (columnNames.isEmpty())
return Collections.emptyMap();

var replicateDomain = ensurePlateReplicateStatsDomain(container, protocolName);
var replicateDomain = ensurePlateReplicateStatsDomain(container, protocolName, true);
var existingFields = getExistingFields(replicateDomain);
var columnMap = new HashMap<String, List<GWTPropertyDescriptor>>();

Expand Down Expand Up @@ -952,7 +952,7 @@ public void updateReplicateStatsDomain(
GWTDomain<GWTPropertyDescriptor> update
) throws ValidationException
{
var replicateDomain = ensurePlateReplicateStatsDomain(protocol);
var replicateDomain = ensurePlateReplicateStatsDomain(protocol, true);
var existingReplicateFields = getExistingFields(replicateDomain);

var originalFields = new HashMap<Integer, GWTPropertyDescriptor>();
Expand Down Expand Up @@ -1085,13 +1085,13 @@ else if (wasValidType)
@Override
public @Nullable Domain getPlateReplicateStatsDomain(ExpProtocol protocol)
{
return getPlateReplicateStatsDomain(protocol.getContainer(), protocol.getName());
return getPlateReplicateStatsDomain(protocol.getContainer(), protocol.getName(), false);
}

private @Nullable Domain getPlateReplicateStatsDomain(Container container, String protocolName)
private @Nullable Domain getPlateReplicateStatsDomain(Container container, String protocolName, boolean forUpdate)
{
String uri = getPlateReplicateStatsDomainUri(container, protocolName);
return PropertyService.get().getDomain(container, uri);
return PropertyService.get().getDomain(container, uri, forUpdate);
}

private String getPlateReplicateStatsDomainUri(Container container, String protocolName)
Expand All @@ -1100,14 +1100,14 @@ private String getPlateReplicateStatsDomainUri(Container container, String proto
return domainKind.generateDomainURI(AssaySchema.NAME, protocolName, container, null);
}

private @NotNull Domain ensurePlateReplicateStatsDomain(ExpProtocol protocol)
private @NotNull Domain ensurePlateReplicateStatsDomain(ExpProtocol protocol, boolean forUpdate)
{
return ensurePlateReplicateStatsDomain(protocol.getContainer(), protocol.getName());
return ensurePlateReplicateStatsDomain(protocol.getContainer(), protocol.getName(), forUpdate);
}

private @NotNull Domain ensurePlateReplicateStatsDomain(Container container, String protocolName)
private @NotNull Domain ensurePlateReplicateStatsDomain(Container container, String protocolName, boolean forUpdate)
{
Domain domain = getPlateReplicateStatsDomain(container, protocolName);
Domain domain = getPlateReplicateStatsDomain(container, protocolName, forUpdate);
if (domain == null)
domain = PropertyService.get().createDomain(container, getPlateReplicateStatsDomainUri(container, protocolName), PlateReplicateStatsDomainKind.NAME);

Expand Down
19 changes: 13 additions & 6 deletions assay/src/org/labkey/assay/plate/PlateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@

import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableList;
import static org.labkey.api.assay.plate.PlateSet.MAX_PLATES;
import static org.labkey.api.assay.plate.WellGroup.Type.SAMPLE;
Expand Down Expand Up @@ -2266,10 +2265,18 @@ public static void deindexPlateSet(Container container, Integer plateSetRowId)
* Returns the domain attached to the Well table,
*/
public @Nullable Domain getPlateMetadataDomain(Container container, User user)
{
return getPlateMetadataDomain(container, user, false);
}

/**
* Returns the domain attached to the Well table,
*/
public @Nullable Domain getPlateMetadataDomain(Container container, User user, boolean forUpdate)
{
// the domain is scoped at the project level (project and subfolder scoping)
String domainURI = PlateMetadataDomainKind.generateDomainURI(getPlateMetadataDomainContainer(container));
return PropertyService.get().getDomain(container, domainURI);
return PropertyService.get().getDomain(container, domainURI, forUpdate);
}

public @Nullable TableInfo getPlateMetadataTable(Container container, User user)
Expand All @@ -2289,9 +2296,9 @@ public Container getPlateMetadataDomainContainer(Container container)
}

@Override
public @NotNull Domain ensurePlateMetadataDomain(Container container, User user) throws ValidationException
public @NotNull Domain ensurePlateMetadataDomain(Container container, User user, boolean forUpdate) throws ValidationException
{
Domain metadataDomain = getPlateMetadataDomain(container, user);
Domain metadataDomain = getPlateMetadataDomain(container, user, forUpdate);

if (metadataDomain == null)
{
Expand All @@ -2311,7 +2318,7 @@ public Container getPlateMetadataDomainContainer(Container container)
*/
public @NotNull List<PlateCustomField> createPlateMetadataFields(Container container, User user, List<GWTPropertyDescriptor> fields) throws Exception
{
Domain metadataDomain = ensurePlateMetadataDomain(container, user);
Domain metadataDomain = ensurePlateMetadataDomain(container, user, true);
DomainKind<?> domainKind = metadataDomain.getDomainKind();

if (!domainKind.canEditDefinition(user, metadataDomain))
Expand All @@ -2338,7 +2345,7 @@ public Container getPlateMetadataDomainContainer(Container container)

public @NotNull List<PlateCustomField> deletePlateMetadataFields(Container container, User user, List<PlateCustomField> fields) throws Exception
{
Domain metadataDomain = getPlateMetadataDomain(container, user);
Domain metadataDomain = getPlateMetadataDomain(container, user, true);

if (metadataDomain == null)
throw new IllegalArgumentException("Unable to remove fields from the domain, the domain was not found.");
Expand Down
2 changes: 1 addition & 1 deletion assay/src/org/labkey/assay/plate/query/WellTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public QueryUpdateService getUpdateService()
{
try
{
domain = PlateManager.get().ensurePlateMetadataDomain(container, user);
domain = PlateManager.get().ensurePlateMetadataDomain(container, user, false);
}
catch (ValidationException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ public IPropertyType getType(Container container, String typeURI)
@Nullable
public DomainImpl getDomain(Container container, String domainURI)
{
DomainDescriptor dd = OntologyManager.getDomainDescriptor(domainURI, container);
return getDomain(container, domainURI, false);
}

@Override
@Nullable
public DomainImpl getDomain(Container container, String domainURI, boolean forUpdate)
{
DomainDescriptor dd = OntologyManager.getDomainDescriptor(domainURI, container, forUpdate);
if (dd == null)
return null;
return new DomainImpl(dd);
Expand All @@ -144,6 +151,16 @@ public Domain getDomain(int domainId)
return new DomainImpl(dd);
}

@Override
@Nullable
public Domain getDomain(int domainId, boolean forUpdate)
{
DomainDescriptor dd = OntologyManager.getDomainDescriptor(domainId);
if (dd == null)
return null;
return new DomainImpl(dd);
}

@Override
@NotNull
public Domain createDomain(Container container, String typeURI, String name)
Expand Down