refactor: Route all GET endpoints to read replica via read_only - #3716
refactor: Route all GET endpoints to read replica via read_only#3716niraj2477 wants to merge 1 commit into
Conversation
Confidence Score: 4/5This should be fixed before merging because a newly created ticket can immediately appear missing during replication lag. Ticket creation redirects directly to a detail endpoint that now reads from the replica and explicitly fails when the replicated row is not yet visible. Files Needing Attention: helpdesk/helpdesk/doctype/hd_ticket/api.py Prompt To Fix All With AI### Issue 1
helpdesk/helpdesk/doctype/hd_ticket/api.py:39
**Replica hides new tickets**
If replication is delayed, the post-creation redirect immediately calls `get_one` against the replica before the new ticket is visible, causing the customer’s successfully created ticket page to fail with “Ticket not found.”
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "refactor: Route all GET endpoints to rea..." | Re-trigger Greptile |
|
|
||
|
|
||
| @frappe.whitelist() | ||
| @frappe.read_only() |
There was a problem hiding this comment.
If replication is delayed, the post-creation redirect immediately calls get_one against the replica before the new ticket is visible, causing the customer’s successfully created ticket page to fail with “Ticket not found.”
Knowledge Base Used: Ticket management
Prompt To Fix With AI
This is a comment left during a code review.
Path: helpdesk/helpdesk/doctype/hd_ticket/api.py
Line: 39
Comment:
**Replica hides new tickets**
If replication is delayed, the post-creation redirect immediately calls `get_one` against the replica before the new ticket is visible, causing the customer’s successfully created ticket page to fail with “Ticket not found.”
**Knowledge Base Used:** [Ticket management](https://app.greptile.com/frappe/-/custom-context/knowledge-base/frappe/helpdesk/-/docs/ticket-management.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Replication is handled by DB, and did not came across such case in high traffic system, If still required this can be updated atleast for this.
There was a problem hiding this comment.
That’s fair—this may be rare in practice, but asynchronous DB replication still allows a newly inserted ticket to be temporarily absent from the replica. Since get_one is commonly called immediately after new, please leave get_one off @frappe.read_only() (or explicitly route that post-create fetch to the primary). The other read endpoints can remain covered by this change.
Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.
|
Tick the box to add this pull request to the merge queue (same as
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3716 +/- ##
===========================================
+ Coverage 73.76% 73.87% +0.10%
===========================================
Files 148 148
Lines 10841 10904 +63
===========================================
+ Hits 7997 8055 +58
- Misses 2844 2849 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@RitvikSardana Can you check if this can be merged? |
This pr routes all the GET endpoint via read_only wrapper so that the read_replica can be used for query.