Rikkola commented on code in PR #7135:
URL: https://github.com/apache/incubator-kie/pull/7135#discussion_r4195646996
##########
drools-core/src/main/java/org/drools/core/phreak/SegmentMemorySupportImpl.java:
##########
@@ -213,14 +213,19 @@ public SegmentMemory
createChildSegmentLazily(LeftTupleNode node) {
@Override
public void initializeChildSegmentsIfNeeded(SegmentMemory smem) {
LeftTupleSinkPropagator sinkPropagator =
smem.getTipNode().getSinkPropagator();
- if (!smem.isEmpty()) {
- return; // this can happen when multiple threads are trying to
initialize the segment
+ if (!smem.isEmpty() && sinkPropagator.size() == 1) {
+ return; // threading guard: single-sink child already initialized
}
+ // When the tip node has multiple sinks (segment split by a sharing
rule), some children
+ // may already have been added to smem while sibling children are
still missing.
+ // Iterate all sinks, create any missing child segment, and add it
only if not already present.
for (LeftTupleSinkNode sink = sinkPropagator.getFirstLeftTupleSink();
sink != null; sink = sink
.getNextLeftTupleSinkNode()) {
SegmentMemory childSmem = PhreakBuilder.isEagerSegmentCreation() ?
createChildSegment(sink)
: createChildSegmentLazily(sink);
- smem.add(childSmem);
+ if (childSmem != null && !smem.contains(childSmem)) {
+ smem.add(childSmem);
Review Comment:
Copilot picked this up in earlier PRs too, but this situation is not
reachable from DRL or executable API. So we leave it
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]