Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/delete document tags slow #4232

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

rkuo-danswer
Copy link
Contributor

Description

Fixes DAN-1543.
https://linear.app/danswer/issue/DAN-1543/slow-doc-tag-deletion-contributor

Credit to @ThomaciousD - #4192

How Has This Been Tested?

[Describe the tests you ran to verify your changes]

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

Copy link

vercel bot commented Mar 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 8, 2025 0:56am

@rkuo-danswer rkuo-danswer marked this pull request as ready for review March 7, 2025 19:57
@rkuo-danswer rkuo-danswer requested a review from a team as a code owner March 7, 2025 19:57
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR optimizes document tag deletion performance and modifies email header handling, with key changes focused on query efficiency and email configuration.

  • Improved orphan tag deletion in /backend/onyx/db/tag.py by replacing outer join/group by with a more efficient NOT EXISTS subquery
  • Added conditional 'From' header check in /backend/onyx/auth/email_utils.py that needs review as missing headers could cause email delivery failures
  • Query optimization removes dependency on SQLAlchemy's func module while maintaining correct tag identification

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +156 to +157
if mail_from:
msg["From"] = mail_from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Removing the 'From' header when mail_from is None will cause email delivery failures. The 'From' header is required by SMTP. Should use EMAIL_FROM as fallback instead.

Suggested change
if mail_from:
msg["From"] = mail_from
msg["From"] = mail_from or EMAIL_FROM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants