You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ingestion hooks always sent generated tasks through the priority RabbitMQ path, even when they targeted the same entity and would return to the same worker thread. Mirrored TTL data therefore added a confirmed publish, broker delivery, parse, and acknowledgement cycle for every source task.
Add a startup-configured bound for processing same-routing-key descendants through the complete TaskExecutor pipeline in a local FIFO. The default of zero preserves queue-only behavior; cross-entity work, overflow, and pending siblings after an inline failure continue through the priority queue.
A saturated benchmark using the real data-mirroring TTL hook and a three-second master-buffer flush improved median throughput from 67 to 207 entities/s and reduced completion time from 29.70s to 9.68s. It also eliminated 2,000 priority publish/deliver/ack cycles and reduced median Mongo updates from 2,314 to 2,004; the database coalescing benefit remains workload-dependent.
This hook is called once for a newly created entity, after `allow_entity_creation` has accepted creation and before the task's datapoints are staged into raw and master persistence.
194
194
The callback receives the new `eid` together with the original `DataPointTask` that caused the entity to be created, so it can inspect the incoming datapoints through `task.data_points`.
195
195
It should not assume that the entity's new state is already readable as a persisted master record, because the creation-triggering task has not been written through the normal persistence path yet.
196
-
The hook may return a list of `DataPointTask` objects, and those tasks are queued back into the ingestion pipeline, where they trigger the usual hooks again.
197
-
Because they originate from ingestion, they are pushed to the **priority** task queue.
196
+
The hook may return a list of `DataPointTask` objects, and those tasks re-enter the ingestion pipeline, where they trigger the usual hooks again.
197
+
Depending on `max_inline_generated_tasks`, same-entity outputs may be processed inline by the current worker; outputs for other entities and same-entity overflow are pushed to the **priority** task queue.
198
198
This registration also supports `refresh=` and `may_change=` for recomputation during module-config refresh; see [Refresh-on-config-change behavior for ingestion hooks](#refresh-on-config-change-behavior-for-ingestion-hooks).
199
199
200
200
Real usage examples:
@@ -258,8 +258,9 @@ If `task.delete` is `True`, `on_task_start` still runs and entity deletion is pe
258
258
259
259
#### Returned tasks recurse through the same pipeline
260
260
261
-
Any `DataPointTask` returned by `on_entity_creation` or `on_new_attr` is sent back to the main task queue and later processed again by `TaskExecutor.process_task`.
262
-
In other words, module-generated datapoints re-enter DP3 exactly like primary datapoints from the API, so they can trigger `on_task_start`, `allow_entity_creation`, `on_entity_creation`, `on_new_attr`, and later snapshot or updater hooks.
261
+
Any `DataPointTask` returned by `on_entity_creation` or `on_new_attr` is processed again by `TaskExecutor.process_task`.
262
+
Depending on worker configuration, a bounded number of same-entity tasks may run inline, while cross-entity tasks and same-entity overflow pass through the priority queue first.
263
+
In either case, module-generated datapoints re-enter the complete ingestion pipeline, so they can trigger `on_task_start`, `allow_entity_creation`, `on_entity_creation`, `on_new_attr`, and later snapshot or updater hooks.
263
264
264
265
## Snapshot-time hooks: periodic processing over stored data
265
266
@@ -610,17 +611,28 @@ This creates a feedback loop:
610
611
611
612
```text
612
613
hook returns DataPointTask(s)
613
-
-> task queue
614
+
-> inline processing or task queue
614
615
-> TaskExecutor.process_task
615
616
-> ingestion hooks run again
616
617
-> data reaches master/raw storage
617
618
-> later snapshot / updater cycles can see it
618
619
```
619
620
620
-
The queueing path differs slightly by hook family.
621
-
Ingestion hooks such as `on_entity_creation` and `on_new_attr` push returned tasks to the priority queue.
622
-
Snapshot hooks and updater hooks push returned tasks to the normal task queue.
623
-
`scheduler_register` callbacks do not have an automatic task-return path.
621
+
The re-entry path differs slightly by hook family.
622
+
For ingestion hooks such as `on_entity_creation` and `on_new_attr`, workers may process a bounded
623
+
number of same-entity outputs inline when `max_inline_generated_tasks` is positive. The source task
624
+
does not count toward the limit, and the allowance is shared by all descendants generated while
625
+
processing it. Outputs for another entity and same-entity outputs above the limit use the priority
626
+
queue. Inline processing still calls the complete `TaskExecutor.process_task` pipeline; it does not
627
+
make buffered writes immediately visible through independent database reads.
628
+
629
+
With the default `max_inline_generated_tasks: 0`, all ingestion-hook outputs use the priority queue,
630
+
matching queue-only behavior. The value is read at worker startup. Enabling inline processing can
631
+
change interleaving with tasks already assigned to the worker and removes the JSON serialization and
632
+
RabbitMQ boundary for eligible outputs, so hooks must not depend on either boundary.
633
+
634
+
Snapshot hooks and updater hooks push returned tasks to the normal task queue and are not eligible for
635
+
this inline path. `scheduler_register` callbacks do not have an automatic task-return path.
0 commit comments