Skip to content

Conversation

@stariy95
Copy link
Member

Another approach to the CAY-2876

This PR introduces cleanup callback in the ReferenceMap keeping flattened paths as is in the ObjectStore and dropping them in sync with the main object map. This is a less reliable fix then before, but it guarantees that there will be no problems with the object store data consistency.

In 5.0 we could experiment a bit more and try something more robust.

@andrus
Copy link
Contributor

andrus commented Mar 10, 2025

+1 . Not pretty, but should work.

@Jugen
Copy link
Contributor

Jugen commented Mar 10, 2025

+1. I was experimenting with changing trackedFlattenedPaths to a WeakHashMap but couldn't successfully write a test case for it, however I prefer this direct approach much more.

@Jugen
Copy link
Contributor

Jugen commented Mar 10, 2025

I was wondering if trackedFlattenedPaths didn't need housekeeping in these two places as well ?

public void postprocessAfterCommit(GraphDiff parentChanges) {
// scan through changed objects, set persistence state to committed
for (Object id : changes.keySet()) {
Persistent object = objectMap.get(id);
switch (object.getPersistenceState()) {
case PersistenceState.DELETED:
objectMap.remove(id);

void processDeletedID(ObjectId nodeId) {
// access object map directly - the method should be called in a synchronized context...
Persistent object = objectMap.get(nodeId);
if (object != null) {
DataObject dataObject = (object instanceof DataObject)
? (DataObject) object
: null;
DataContextDelegate delegate;
switch (object.getPersistenceState()) {
case PersistenceState.COMMITTED:
case PersistenceState.HOLLOW:
case PersistenceState.DELETED:
// consult delegate
delegate = context.nonNullDelegate();
if (dataObject == null || delegate.shouldProcessDelete(dataObject)) {
objectMap.remove(nodeId);

@stariy95
Copy link
Member Author

@Jugen Yes, you are correct, we should clean tracked paths in those places too.

 - clean up tracked paths when corresponding object is removed
@stariy95 stariy95 merged commit 7ea437d into apache:STABLE-4.2 Mar 11, 2025
18 checks passed
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