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

Rule engine obj reloading #2396

Merged
merged 6 commits into from
Jul 15, 2019

Conversation

lchanmann
Copy link
Contributor

No description provided.

src/foam/nanos/ruler/RuleEngine.java Outdated Show resolved Hide resolved
Copy link
Collaborator

@jlhughes jlhughes left a comment

Choose a reason for hiding this comment

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

Approved. Still request @kgrgreer reviews and approves.

}
}

old = old.fclone();
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you put this line in an else clause for the above 'if' you'll save unnecessary cloneing when you create an object on line 238.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, you're right.

@@ -161,11 +163,17 @@ private void asyncApplyRules(List<Rule> rules, FObject obj, FObject oldObj) {
if ( rule.getAsyncAction() != null
&& rule.f(x, obj, oldObj)
) {
// We assume the original object `obj` is stale when running after rules.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you describe a but that this fixes? If your action is dependent upon whether the object has been written in to the DAO yet or not, then I think we're setting ourselves up for race conditions and your rule would be better of running in an agency at a specific time. Or we should update the async logic to always fetch the latest object from the DAO, what state from the obj do you want that won't make it to nu ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have before rules (sync and async) that can update the object by setting its properties. When the next async rule is run the object might not have been saved since saving happen on a separate CMD operation https://github.com/foam-framework/foam2/blob/master/src/foam/nanos/ruler/RulerDAO.js#L208.

As discussed with @kgrgreer, @jlhughes, and @nanoscott, we would have this kind of race condition because there is no synchronization inside the rule engine itself which is something needs to be addressed properly. On the other hand, we would need this temporary fix for our current release to not block the operation team from using IdentityMind integration.

I will be working on creating integration tests for IdentityMind then refactoring the rule engine to support object locking so that reloading would just be a simple find().

return obj;
}
} else {
old = old.fclone();
Copy link
Collaborator

Choose a reason for hiding this comment

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

@lchanmann I think Kevin mentioned this, it's not needed.

@lchanmann
Copy link
Contributor Author

Ticket for adding synchronization on rule engine - #2401.

@kgrgreer can we have this PR in?

@jlhughes jlhughes merged commit 927d8eb into foam-framework:master Jul 15, 2019
@lchanmann lchanmann deleted the RuleEngineObjReloading branch July 15, 2019 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants