:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(trino): stop filing a vanished query's page fetch as an exception (#119350)
Tom Owersce1d55361aae
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/trino/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/trino/source.pyindex 9ad9bc5ef897..5b5ee7801b9b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/trino/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/trino/source.py@@ -26,6 +26,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.generated_from products.warehouse_sources.backend.temporal.data_imports.sources.trino.trino import (TRINO_COLUMN_NOT_FOUND_ERROR,TRINO_KNOWN_ERROR_MESSAGES,+ TRINO_QUERY_NOT_FOUND_ERROR,TRINO_SCHEMA_NOT_FOUND_ERROR,TRINO_TABLE_NOT_FOUND_ERROR,TRINO_WORKER_NODE_ERROR,@@ -286,6 +287,7 @@ class TrinoSource(SQLSource[TrinoSourceConfig], ValidateDatabaseHostMixin):}def get_retryable_errors(self) -> set[str]:- # The coordinator only raises this after exhausting its own attempts to reach the worker,- # so it reaches us already a self-recovering vendor-side blip.- return {TRINO_WORKER_NODE_ERROR}+ # Both are self-recovering vendor-side blips: the coordinator only raises the worker-node+ # error after exhausting its own attempts to reach the worker, and a fresh attempt gets a+ # new query ID, so a query the coordinator no longer holds ("Query not found") clears itself.+ return {TRINO_WORKER_NODE_ERROR, TRINO_QUERY_NOT_FOUND_ERROR}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/trino/tests/test_trino.py b/products/warehouse_sources/backend/temporal/data_imports/sources/trino/tests/test_trino.pyindex 52d7bf335858..10dfc8a8672a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/trino/tests/test_trino.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/trino/tests/test_trino.py@@ -695,6 +695,14 @@ def test_worker_node_communication_failures_are_classified_as_retryable() -> Nonassert error_message_matches(message, TrinoSource().get_retryable_errors())+def test_query_not_found_is_classified_as_retryable() -> None:+ # The exact wrapping `trino.dbapi.Cursor.fetchone()` does for the driver's `HttpError` on a 404+ # response, which is what a later page fetch sees once the coordinator no longer holds the query.+ message = "error 404: b'Error 404 Not Found: Query not found'"++ assert error_message_matches(message, TrinoSource().get_retryable_errors())++def test_build_pipeline_refuses_a_disallowed_host_before_connecting() -> None:with (patch(f"{_TRINO_MODULE}.connect_trino") as mock_connect,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/trino/trino.py b/products/warehouse_sources/backend/temporal/data_imports/sources/trino/trino.pyindex 92296bf52c9d..1b4c5ee6f71a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/trino/trino.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/trino/trino.py@@ -102,6 +102,13 @@ TRINO_COLUMN_NOT_FOUND_ERROR = (# by the time it reaches us the worker has likely crashed or is overloaded — a vendor-side blip a# fresh query normally clears, not a PostHog or customer problem.TRINO_WORKER_NODE_ERROR = "too many errors talking to a worker node"+# The coordinator's own fixed wording when a later page fetch names a query ID it no longer holds —+# the query already finished and was purged, a coordinator restart/failover dropped its in-memory+# state, or a load balancer sent the follow-up request to a coordinator that never saw the query.+# `trino.dbapi.Cursor.fetchone()` wraps the driver's `HttpError` for this response into an+# `OperationalError`. A fresh query on the next sync attempt gets a new query ID, so this clears on+# its own — not a PostHog or customer problem.+TRINO_QUERY_NOT_FOUND_ERROR = "Query not found"# Every message `trino_error_to_message` produces for a recognized failure. The source lists them as# its own error patterns, so the API shows the message instead of a generic one.