feat(ai): bound GMS requests and never replay one GMS may have run
Stack. This is one PR in a series that adds a built-in MCP server to DataHub Core. It is based on na--mcp-read-seams (the previous PR in the stack); review only its own commit. It changes only the shared datahub-core-mcp-tools package and datahub-ai-service. Everything user-facing is behind a GMS feature flag, MCP_SERVER_ENABLED, off by default (added in #21349).
Stack so far:
- #21332
- #21333
- #21334
- #21335
- #21336
- #21337
- #21338
- #21339
- #21340
- #21341
- #21342
- #21343
- #21344 ā this PR
- #21345
- #21346
- #21347
- #21348
- #21349
- #21350
- #21351
- #21352
- #21353
- #21435
- #21436
- #21437
- #21438
- #21439
- #21440
- #21441
- #21442
- #21443
- #21444
- #21445
- #21447
- #21501
- #21502
- #21503
- #21504
- #21505
- #21506
- #21507
- #21508
- #21509
- #21510
- #21511
- #21512
What this does
Caller clients no longer use the SDK's default retries, which resend any
method, POST included, on 5xx responses and read timeouts with exponential
backoff. A GraphQL mutation could be applied twice, and a slow GMS could
hold one call for minutes.
- Retries only cover requests GMS never ran: refused connections and 429s
(honoring Retry-After), at most twice. - DATAHUB_AI_TOOL_TIME_LIMIT_SECONDS (default 300) bounds how long one tool
call keeps sending requests to GMS. The worker thread can't be
interrupted, so the limit is checked before each request: past it, the
next request fails with a ToolError and is not sent, and a request in
flight gets only the time left. The worker keeps its client until it
returns, so nothing is closed under it. - DATAHUB_AI_GMS_TIMEOUT_SECONDS stays the per-request connect/read bound.
- The client factory moves to its own module; execute_graphql passes
ToolErrors through unchanged.
Tests run a scripted HTTP server: 5xx and read timeouts are sent once, 429s
are retried, and the time limit stops further requests.
Testing
Scripted HTTP server counts requests; live deadline error on OSS.
Checklist
- The PR conforms to DataHub's Contributing Guideline (particularly PR Title Format)
- Tests for the changes have been added/updated (if applicable)
- Docs related to the changes have been added/updated (if applicable). The MCP docs come later in the stack.
- For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes. The release notes come later in the stack.
š¤ Generated with Claude Code