Alejandro Diaz
06/27/2024, 11:12 AMMarvin
06/27/2024, 11:12 AMAlejandro Diaz
06/27/2024, 11:14 AM{
"id": "1e324f8f-a4cb-490f-bc45-b16b819d1daa",
"account": "aca43483-5caa-4698-9330-0835d392b42a",
"event": "historical.upload.event.c510dc2e-8051-4207-9163-8fef58fa51f5.1719486621168471253",
"occurred": "2024-06-27T11:10:21.168Z",
"payload": {
"upload_id": "c510dc2e-8051-4207-9163-8fef58fa51f5",
"data_requester_id": "749f3b6b-bc94-4648-80fe-cf8fa5a9bfea",
"framework_id": "0a5038be-6820-46fe-b1e2-835749825329",
"reporting_period_start": "2011-01-01",
"reporting_frequency": "Annually",
"uploaded_by_id": "e7e479c3-c607-4822-8fa9-38bef9676bca",
"upload_date": "2024-06-27T11:10:21.161684",
"file_registry_id": "d34e639a-80df-4504-9f5a-74bb7c4dd40a",
"is_non_company_use_case": false,
"resubmission": true
},
"received": "2024-06-27T11:10:21.354Z",
"related": [],
"resource": {
"prefect.resource.id": "data.api.upload.c510dc2e-8051-4207-9163-8fef58fa51f5",
"prefect.resource.name": "trigger-historical-upload",
"prefect.resource.role": "trigger"
},
"workspace": "12384c92-d7a1-4bcd-a005-37340fd6507c"
}
Marvin
06/27/2024, 11:14 AMThis is the event. Anything that doesn't look right?```{ "id": "1e324f8f-a4cb-490f-bc45-b16b819d1daa", "account": "aca43483-5caa-4698-9330-0835d392b42a", "event": "historical.upload.event.c510dc2e-8051-4207-9163-8fef58fa51f5.1719486621168471253", "occurred": "2024-06-27T111021.168Z", "payload": { "upload_id": "c510dc2e-8051-4207-9163-8fef58fa51f5", "data_requester_id": "749f3b6b-bc94-4648-80fe-cf8fa5a9bfea", "framework_id": "0a5038be-6820-46fe-b1e2-835749825329", "reporting_period_start": "2011-01-01", "reporting_frequency": "Annually", "uploaded_by_id": "e7e479c3-c607-4822-8fa9-38bef9676bca", "upload_date": "2024-06-27T111021.
Alejandro Diaz
06/27/2024, 11:15 AM{
"id": "1e324f8f-a4cb-490f-bc45-b16b819d1daa",
"account": "aca43483-5caa-4698-9330-0835d392b42a",
"event": "historical.upload.event.c510dc2e-8051-4207-9163-8fef58fa51f5.1719486621168471253",
"occurred": "2024-06-27T11:10:21.168Z",
"payload": {
"upload_id": "c510dc2e-8051-4207-9163-8fef58fa51f5",
},
"received": "2024-06-27T11:10:21.354Z",
"related": [],
"resource": {
"prefect.resource.id": "data.api.upload.c510dc2e-8051-4207-9163-8fef58fa51f5",
"prefect.resource.name": "trigger-historical-upload",
"prefect.resource.role": "trigger"
},
"workspace": "12384c92-d7a1-4bcd-a005-37340fd6507c"
}
Marvin
06/27/2024, 11:15 AMoccurred
and received
timestamps, might be triggering the automation twice.
3. Resource Role and Name: Ensure that these are uniquely assigned and there isn't another part of your system emitting a similar event that matches these conditions:
json
"prefect.resource.name": "trigger-historical-upload"
"prefect.resource.role": "trigger"
4. Timestamp Precision: The occurred
and received
timestamps are very close (186 ms apart). Ensure that your system’s timing or retry mechanism isn’t inadvertently treating the same event as different.
5. Related Events: Although the related
array is empty, ensure that any related events aren’t causing a duplicate trigger indirectly by design.
6. General Logging and Monitoring: Implement comprehensive logging around the event listening and processing areas to catch potential duplicate emissions or misfires.
Given your raw event:
json
{
"id": "1e324f8f-a4cb-490f-bc45-b16b819d1daa",
"account": "aca43483-5caa-4698-9330-0835d392b42a",
"event": "historical.upload.event.c510dc2e-8051-4207-9163-8fef58fa51f5.1719486621168471253",
"occurred": "2024-06-27T11:10:21.168Z",
"payload": {
"upload_id": "c510dc2e-8051-4207-9163-8fef58fa51f5"
},
"received": "2024-06-27T11:10:21.354Z",
"related": [],
"resource": {
"prefect.resource.id": "data.api.upload.c510dc2e-8051-4207-9163-8fef58fa51f5",
"prefect.resource.name": "trigger-historical-upload",
"prefect.resource.role": "trigger"
},
"workspace": "12384c92-d7a1-4bcd-a005-37340fd6507c"
}
To debug:
- Ensure no secondary process is emitting.
- Log events to identify if duplicates stem from retries or other parts of your infrastructure.
- Consider adding mechanisms to ignore events with the same id
processed within a short timeframe.
For more detailed understanding, reviewing the automation setup and event listeners' code might help pinpoint the exact cause.Marvin
06/27/2024, 2:34 PMThis event sometimes triggers just one automation (as expected), but other times executes several instances of the same automation, what's wrong?```{ "id": "aca43483-879d-4217-9fe9-379e6b81fb1f", "account": "f915df50-5caa-4698-9330-0835d392b42a", "event": "historical.upload.event.c510dc2e-8051-4207-9163-8fef58fa51f5", "occurred": "2024-06-27T141906.754Z", "payload": { "upload_id": "c510dc2e-8051-4207-9163-8fef58fa51f5", "resubmission": true }, "received": "2024-06-27T143120.374Z", "related": [], "resource": { "prefect.resource.id": "novata.data.api.upload.c510dc2e-8051-4207-9163-8fef58fa51f5", "prefect.resource.name": "trigger-historical-upload", "prefect.resource.role": "trigger" }, "workspace": "38684c92-d7a1-4bcd-a005-37340fd650
Alejandro Diaz
06/27/2024, 2:36 PM{
"id": "aca43483-879d-4217-9fe9-379e6b81fb1f",
"account": "f915df50-5caa-4698-9330-0835d392b42a",
"event": "historical.upload.event.c510dc2e-8051-4207-9163-8fef58fa51f5",
"occurred": "2024-06-27T14:19:06.754Z",
"payload": {
"upload_id": "1234"
},
"received": "2024-06-27T14:31:20.374Z",
"related": [],
"resource": {
"prefect.resource.id": "novata.data.api.upload.c510dc2e-8051-4207-9163-8fef58fa51f5",
"prefect.resource.name": "trigger-historical-upload",
"prefect.resource.role": "trigger"
},
"workspace": "38684c92-d7a1-4bcd-a005-37340fd6507c"
}
I can provide the automation config if neededMarvin
06/27/2024, 2:36 PMAlejandro Diaz
06/27/2024, 2:39 PMAlejandro Diaz
06/27/2024, 2:39 PM{
"type": "event",
"match": {
"prefect.resource.id": "novata.data.api.upload.*"
},
"match_related": {},
"after": [],
"expect": [
"historical.upload.event.*"
],
"for_each": [],
"posture": "Reactive",
"threshold": 1,
"within": 0
}
Events are only emitted once, and each automation triggers one flowMarvin
06/27/2024, 2:40 PM"event"
.
2. Match Criteria: The automation is set to match events where prefect.resource.id
follows the pattern novata.data.api.upload.*
.
3. Expectations: It expects events with names pattern-matching historical.upload.event.*
.
4. Posture: The automation posture is set to "Reactive"
.
5. Threshold: The threshold is set to 1
, meaning it triggers when at least one event matches.
6. Within: Set to 0
, meaning there's no time constraint applied for event occurrence.
## Potential Issues and Fixes
### Event Emission
You mentioned that events are only emitted once. It’s important to log or trace the system emitting these events to confirm that no duplicates are generated at this step. Even minor variations in the emitted event might cause multiple triggers.
### Automation Configuration
While the configuration seems appropriate at first glance, there are a few areas you might want to reconsider or investigate further:
1. Idempotency: Make sure the flow triggered by this automation can handle repeated executions gracefully. This often isn't part of the automation configuration but is rather an aspect of the flow's design.
2. Monitor Event Listeners: Ensure that your event listeners do not inadvertently process the same event multiple times. Enhanced logging around event consumption will help clarify if and why this occurs.
3. Match Patterns: Your match pattern and expectations are broad. Consider providing more specific patterns to see if that reduces the multiple triggers:
json
"match": {
"prefect.resource.id": "novata.data.api.upload.c510dc2e-8051-4207-9163-8fef58fa51f5"
},
"expect": [
"historical.upload.event.c510dc2e-8051-4207-9163-8fef58fa51f5"
]
4. Concurrency Control: If feasible, introduce a mechanism to prevent concurrent execution of the same flow. This can be achieved by maintaining a state or lock to avoid triggering the same automation multiple times.
### Review Provided Event Example
Given your example event:
json
{
"id": "aca43483-879d-4217-9fe9-379e6b81fb1f",
"account": "f915df50-5caa-4698-9330-0835d392b42a",
"event": "historical.upload.event.c510dc2e-8051-4207-9163-8fef58fa51f5",
"occurred": "2024-06-27T14:19:06.754Z",
"payload": {
"upload_id": "1234"
},
"received": "2024-06-27T14:31:20.374Z",
"related": [],
"resource": {
"prefect.resource.id": "novata.data.api.upload.c510dc2e-8051-4207-9163-8fef58fa51f5",
"prefect.resource.name": "trigger-historical-upload",
"prefect.resource.role": "trigger"
},
"workspace": "38684c92-d7a1-4bcd-a005-37340fd6507c"
}
This configuration is acceptable, but varying emission times and payload minutiae can cause multiple triggers.
### Summary
#### Immediate Steps:
1. Add Detailed Logging: Ensure that every step from event emission, through matching, to flow execution is logged for diagnosis.
2. Verify Idempotency: Design and test your flows to handle repeated triggers gracefully.
3. Adjust Patterns: Narrow down matching and expectation patterns to be as specific as possible, reducing scope for misfires.
4. Concurrency Control: Wherever feasible, implement locks or state checks to prevent redundant flow executions.
These actions should help identify and resolve the underlying reasons for multiple triggers of the same automation.