Skip to content

Commit 4458c53

Browse files
authored
fix: processor concurrency issue on startup (#2328)
--------- Signed-off-by: Attila Mészáros <csviri@gmail.com>
1 parent 6a6ce38 commit 4458c53

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventProcessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ public synchronized void stop() {
400400
}
401401

402402
@Override
403-
public void start() throws OperatorException {
403+
public synchronized void start() throws OperatorException {
404+
log.debug("Starting event processor: {}", this);
404405
// on restart new executor service is created and needs to be set here
405406
executor = controllerConfiguration.getConfigurationService().getExecutorServiceManager()
406407
.reconcileExecutorService();
@@ -410,6 +411,7 @@ public void start() throws OperatorException {
410411

411412
private void handleAlreadyMarkedEvents() {
412413
for (var state : resourceStateManager.resourcesWithEventPresent()) {
414+
log.debug("Handling already marked event on start. State: {}", state);
413415
handleMarkedEventForResource(state);
414416
}
415417
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ private PostExecutionControl<P> handleDispatch(ExecutionScope<P> executionScope)
7171
throws Exception {
7272
P originalResource = executionScope.getResource();
7373
var resourceForExecution = cloneResource(originalResource);
74-
log.debug("Handling dispatch for resource {}", getName(originalResource));
74+
log.debug("Handling dispatch for resource name: {} namespace: {}", getName(originalResource),
75+
originalResource.getMetadata().getNamespace());
7576

7677
final var markedForDeletion = originalResource.isMarkedForDeletion();
7778
if (markedForDeletion && shouldNotDispatchToCleanupWhenMarkedForDeletion(originalResource)) {

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ResourceState.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,15 @@ public void unMarkEventReceived() {
111111
break;
112112
}
113113
}
114+
115+
@Override
116+
public String toString() {
117+
return "ResourceState{" +
118+
"id=" + id +
119+
", underProcessing=" + underProcessing +
120+
", retry=" + retry +
121+
", eventing=" + eventing +
122+
", rateLimit=" + rateLimit +
123+
'}';
124+
}
114125
}

0 commit comments

Comments
 (0)