You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "tkobayas (via GitHub)" <gi...@apache.org> on 2025/05/13 07:01:04 UTC
[PR] [incubator-kie-drools-6339] Rule fires again after restoring session … [incubator-kie-drools]
tkobayas opened a new pull request, #6341:
URL: https://github.com/apache/incubator-kie-drools/pull/6341
…and calling fireAllRules
**Issue**:
* https://github.com/apache/incubator-kie-drools/issues/6339
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-drools-6339] Rule fires again after restoring session … [incubator-kie-drools]
Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas commented on code in PR #6341:
URL: https://github.com/apache/incubator-kie-drools/pull/6341#discussion_r2086114159
##########
drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java:
##########
@@ -85,8 +85,8 @@ public InternalWorkingMemory init(InternalWorkingMemory session, PersistedSessio
}
private void onWorkingMemoryAction(InternalWorkingMemory session, PropagationEntry entry) {
- if (entry instanceof PropagationEntry.Insert) {
- InternalFactHandle fh = ((PropagationEntry.Insert) entry).getHandle();
+ if (entry instanceof PropagationEntry.Insert || entry instanceof PropagationEntry.Update) {
+ InternalFactHandle fh = ((PropagationEntry.AbstractPropagationEntry) entry).getHandle();
Review Comment:
`SimpleStoreRuntimeEventListener.objectUpdated` stores the updated object as "propagated = false" -> https://github.com/apache/incubator-kie-drools/blob/10.0.0/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java#L127
It helps in the case:
- `ksession.update` -> JVM crashes -> restore the session (= the non-propagated objects are inserted) -> fireAllRules -> fire! (GOOD)
, but it cause a problem in this case:
- `update` in RHS, so the updated objects are evaluated and rules are fired. -> but `propagated` remains false -> JVM crashes -> restore the session (= the non-propagated objects are inserted) -> fireAllRules -> the same rules are fired again (BAD)
So the fix is to stores the updated object as "propagated = true" when propagated. (not only inserted pbjects)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-drools-6339] Rule fires again after restoring session … [incubator-kie-drools]
Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas commented on code in PR #6341:
URL: https://github.com/apache/incubator-kie-drools/pull/6341#discussion_r2086213092
##########
drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java:
##########
@@ -85,8 +85,8 @@ public InternalWorkingMemory init(InternalWorkingMemory session, PersistedSessio
}
private void onWorkingMemoryAction(InternalWorkingMemory session, PropagationEntry entry) {
- if (entry instanceof PropagationEntry.Insert) {
- InternalFactHandle fh = ((PropagationEntry.Insert) entry).getHandle();
+ if (entry instanceof PropagationEntry.Insert || entry instanceof PropagationEntry.Update) {
+ InternalFactHandle fh = ((PropagationEntry.AbstractPropagationEntry) entry).getHandle();
if (fh.isValid()) {
WorkingMemoryEntryPoint ep = fh.getEntryPoint(session);
((SimpleReliableObjectStore) ep.getObjectStore()).putIntoPersistedStorage(fh, true);
Review Comment:
`PropagationEntry.Insert` and `PropagationEntry.Update` are subclass of `PropagationEntry.AbstractPropagationEntry`. Adding such `if` looks too much :thinking:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-drools-6339] Rule fires again after restoring session … [incubator-kie-drools]
Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas commented on code in PR #6341:
URL: https://github.com/apache/incubator-kie-drools/pull/6341#discussion_r2086114159
##########
drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java:
##########
@@ -85,8 +85,8 @@ public InternalWorkingMemory init(InternalWorkingMemory session, PersistedSessio
}
private void onWorkingMemoryAction(InternalWorkingMemory session, PropagationEntry entry) {
- if (entry instanceof PropagationEntry.Insert) {
- InternalFactHandle fh = ((PropagationEntry.Insert) entry).getHandle();
+ if (entry instanceof PropagationEntry.Insert || entry instanceof PropagationEntry.Update) {
+ InternalFactHandle fh = ((PropagationEntry.AbstractPropagationEntry) entry).getHandle();
Review Comment:
`SimpleStoreRuntimeEventListener.objectUpdated` stores the updated object as "propagated = false" -> https://github.com/apache/incubator-kie-drools/blob/10.0.0/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java#L127
It helps in the case:
- `ksession.update` -> JVM crashes -> restore the session (= the non-propagated objects are inserted) -> fireAllRules -> fire! (GOOD)
, but it causes a problem in this case:
- `update` in RHS, so the updated objects are evaluated and rules are fired. -> but `propagated` remains false -> JVM crashes -> restore the session (= the non-propagated objects are inserted) -> fireAllRules -> the same rules are fired again (BAD)
So the fix is to stores the updated object as "propagated = true" when propagated. (not only inserted pbjects)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-drools-6339] Rule fires again after restoring session … [incubator-kie-drools]
Posted by "yesamer (via GitHub)" <gi...@apache.org>.
yesamer commented on code in PR #6341:
URL: https://github.com/apache/incubator-kie-drools/pull/6341#discussion_r2086230438
##########
drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java:
##########
@@ -85,8 +85,8 @@ public InternalWorkingMemory init(InternalWorkingMemory session, PersistedSessio
}
private void onWorkingMemoryAction(InternalWorkingMemory session, PropagationEntry entry) {
- if (entry instanceof PropagationEntry.Insert) {
- InternalFactHandle fh = ((PropagationEntry.Insert) entry).getHandle();
+ if (entry instanceof PropagationEntry.Insert || entry instanceof PropagationEntry.Update) {
+ InternalFactHandle fh = ((PropagationEntry.AbstractPropagationEntry) entry).getHandle();
if (fh.isValid()) {
WorkingMemoryEntryPoint ep = fh.getEntryPoint(session);
((SimpleReliableObjectStore) ep.getObjectStore()).putIntoPersistedStorage(fh, true);
Review Comment:
@tkobayas feel free to ignore that suggestion :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-drools-6339] Rule fires again after restoring session … [incubator-kie-drools]
Posted by "mariofusco (via GitHub)" <gi...@apache.org>.
mariofusco merged PR #6341:
URL: https://github.com/apache/incubator-kie-drools/pull/6341
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-drools-6339] Rule fires again after restoring session … [incubator-kie-drools]
Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas commented on code in PR #6341:
URL: https://github.com/apache/incubator-kie-drools/pull/6341#discussion_r2086114159
##########
drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java:
##########
@@ -85,8 +85,8 @@ public InternalWorkingMemory init(InternalWorkingMemory session, PersistedSessio
}
private void onWorkingMemoryAction(InternalWorkingMemory session, PropagationEntry entry) {
- if (entry instanceof PropagationEntry.Insert) {
- InternalFactHandle fh = ((PropagationEntry.Insert) entry).getHandle();
+ if (entry instanceof PropagationEntry.Insert || entry instanceof PropagationEntry.Update) {
+ InternalFactHandle fh = ((PropagationEntry.AbstractPropagationEntry) entry).getHandle();
Review Comment:
`SimpleStoreRuntimeEventListener.objectUpdated` stores the updated object as "propagated = false" -> https://github.com/apache/incubator-kie-drools/blob/10.0.0/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java#L127
It helps in the case:
- `ksession.update` -> JVM crashes -> restore the session (= the non-propagated objects are inserted) -> fireAllRules -> fire! (GOOD)
, but it causes a problem in this case:
- `update` in RHS, so the updated objects are evaluated and rules are fired. -> but `propagated` remains false -> JVM crashes -> restore the session (= the non-propagated objects are inserted) -> fireAllRules -> the same rules are fired again (BAD)
So the fix is to stores the updated object as "propagated = true" when propagated. (not only inserted objects)
@mariofusco If you have any concern, please share.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-drools-6339] Rule fires again after restoring session … [incubator-kie-drools]
Posted by "tkobayas (via GitHub)" <gi...@apache.org>.
tkobayas commented on code in PR #6341:
URL: https://github.com/apache/incubator-kie-drools/pull/6341#discussion_r2086114159
##########
drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java:
##########
@@ -85,8 +85,8 @@ public InternalWorkingMemory init(InternalWorkingMemory session, PersistedSessio
}
private void onWorkingMemoryAction(InternalWorkingMemory session, PropagationEntry entry) {
- if (entry instanceof PropagationEntry.Insert) {
- InternalFactHandle fh = ((PropagationEntry.Insert) entry).getHandle();
+ if (entry instanceof PropagationEntry.Insert || entry instanceof PropagationEntry.Update) {
+ InternalFactHandle fh = ((PropagationEntry.AbstractPropagationEntry) entry).getHandle();
Review Comment:
`SimpleStoreRuntimeEventListener.objectUpdated` stores the updated object as "propagated = false" -> https://github.com/apache/incubator-kie-drools/blob/10.0.0/drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java#L127
It helps in the case:
- `ksession.update` -> JVM crashes -> restore the session (= the non-propagated objects are inserted) -> fireAllRules -> fire! (GOOD)
, but it causes a problem in this case:
- `update` in RHS, so the updated objects are evaluated and rules are fired. -> but `propagated` remains false -> JVM crashes -> restore the session (= the non-propagated objects are inserted) -> fireAllRules -> the same rules are fired again (BAD)
So the fix is to store the updated object as "propagated = true" when propagated. (not only inserted objects)
@mariofusco If you have any concern, please share.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] [incubator-kie-drools-6339] Rule fires again after restoring session … [incubator-kie-drools]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #6341:
URL: https://github.com/apache/incubator-kie-drools/pull/6341#discussion_r2086190195
##########
drools-reliability/drools-reliability-core/src/main/java/org/drools/reliability/core/ReliableSessionInitializer.java:
##########
@@ -85,8 +85,8 @@ public InternalWorkingMemory init(InternalWorkingMemory session, PersistedSessio
}
private void onWorkingMemoryAction(InternalWorkingMemory session, PropagationEntry entry) {
- if (entry instanceof PropagationEntry.Insert) {
- InternalFactHandle fh = ((PropagationEntry.Insert) entry).getHandle();
+ if (entry instanceof PropagationEntry.Insert || entry instanceof PropagationEntry.Update) {
+ InternalFactHandle fh = ((PropagationEntry.AbstractPropagationEntry) entry).getHandle();
if (fh.isValid()) {
WorkingMemoryEntryPoint ep = fh.getEntryPoint(session);
((SimpleReliableObjectStore) ep.getObjectStore()).putIntoPersistedStorage(fh, true);
Review Comment:
Consider verifying that casting entry to PropagationEntry.AbstractPropagationEntry is valid for all cases of PropagationEntry.Update to avoid potential ClassCastExceptions. If different update types exist, consider a more specific type check or handling logic.
```suggestion
if (entry instanceof PropagationEntry.AbstractPropagationEntry) {
InternalFactHandle fh = ((PropagationEntry.AbstractPropagationEntry) entry).getHandle();
if (fh.isValid()) {
WorkingMemoryEntryPoint ep = fh.getEntryPoint(session);
((SimpleReliableObjectStore) ep.getObjectStore()).putIntoPersistedStorage(fh, true);
}
} else {
// Log a warning or handle the unexpected case
System.err.println("Warning: Unsupported PropagationEntry type: " + entry.getClass().getName());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org