Skip to content

Fix MXLookup UDF timeout errors#129

Open
cmttt wants to merge 1 commit intomainfrom
ls/fix-mxlookup-timeouts
Open

Fix MXLookup UDF timeout errors#129
cmttt wants to merge 1 commit intomainfrom
ls/fix-mxlookup-timeouts

Conversation

@cmttt
Copy link
Collaborator

@cmttt cmttt commented Jan 30, 2026

Summary

  • Configure DNS resolver with 0.5s query timeout and 1.0s lifetime (was using defaults which could take 30+ seconds)
  • Add 2.0s gevent timeout wrapping entire execute method (covers both MX + A lookups)
  • Add metrics: mx_lookup.execute.{success,dns_timeout,gevent_timeout,no_record}
  • Catch DNSTimeout explicitly and convert to ExpectedUdfException

Test plan

  • Added test for DNS timeout scenario
  • Deploy to staging and monitor mx_lookup.execute.* metrics
  • Verify timeout errors decrease significantly

- Configure DNS resolver with 0.5s query timeout and 1.0s lifetime
- Add 2.0s gevent timeout wrapping entire execute method
- Add metrics for success, dns_timeout, gevent_timeout, no_record
- Catch DNSTimeout explicitly and convert to ExpectedUdfException
- Add test for DNS timeout scenario
domain = mx_answer.exchange.to_text()
a_record_answers = resolver.resolve(domain, 'A', raise_on_no_answer=True)
except (NoAnswer, NXDOMAIN, YXDOMAIN, NoNameservers):
with gevent.Timeout(MXLOOKUP_GEVENT_TIMEOUT, False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think you don't want False there if you want to catch the exception below

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