Files
openobserve/src/super_cluster_queue
Subhra264andYashodhan Joshi 6fa36d6d43 fix: create scheduled_job if it does not exist in another super cluster region (#8536)
### **User description**
If one region in super cluster for some reason does not have the
scheduled_job, and it gets an "Update" event from another region to
update the scheduled_job, it will always fail because it does not exist
in the region. In this pr, it will first check if it exists, otherwise
we create the scheduled job if the module record is present in the db.


___

### **PR Type**
Enhancement, Tests


___

### **Description**
- Add parser for `module_key` extraction

- Fallback create missing scheduled triggers

- Improve DB checks before trigger creation

- Add unit tests for parser and scheduling


___

### Diagram Walkthrough


```mermaid
flowchart LR
  A["Super-cluster UPDATE message"] -- "check existing trigger" --> B{"scheduler::get OK?"}
  B -- "Yes" --> C["scheduler::update_trigger(clone=true)"]
  B -- "No" --> D["Validate module existence by type"]
  D -- "exists" --> E["scheduler::push(create)"]
  D -- "missing/invalid" --> F["warn/skip"]
  G["handlers.rs"] -- "parse module_key" --> H["get_pipeline_info_from_module_key()"]
  H -- "used by" --> G
  H -- "used by" --> D
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>handlers.rs</strong><dd><code>Refactor module_key
parsing and add tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

src/service/alerts/scheduler/handlers.rs

<ul><li>Replace inline <code>module_key</code> parsing with helper.<br>
<li> Fix API usage: pass references to <code>get_by_id</code> and
<code>process_batch</code>.<br> <li> Add
<code>get_pipeline_info_from_module_key</code> utility.<br> <li> Add
comprehensive unit tests for parsing and scheduling timestamps.</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8536/files#diff-5eca8995a88fcecb6d6b8efd3c7c4496f4a96a4b060fb4ed85593574f7cf49eb">+362/-18</a></td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>scheduler.rs</strong><dd><code>Create missing triggers
with module existence checks</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

src/super_cluster_queue/scheduler.rs

<ul><li>Add creation path when scheduler job missing on region.<br> <li>
Validate module existence per type before creation.<br> <li> Use ORM
client to check alerts/reports presence.<br> <li> Improve imports and
alert name lookup path.</ul>


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8536/files#diff-000247f033ce3110163f4c4fd48eb4c462ec1b23f93f6694b633f42fa4ada822">+87/-14</a>&nbsp;
</td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

---------

Co-authored-by: Yashodhan Joshi <yashodhan@openobserve.ai>
2025-09-23 10:24:31 +05:30
..
2025-07-09 19:16:13 +05:30
2025-07-21 22:15:41 +05:30
2025-07-20 15:03:43 +05:30
2025-07-09 19:16:13 +05:30
2025-07-09 19:16:13 +05:30
2025-07-09 19:16:13 +05:30
2025-07-21 22:15:41 +05:30
2025-07-09 19:16:13 +05:30