ALC-2002: Timed out
Something took longer than it was allowed to. Usually a statement ran past the connection’s time limit and Postgres stopped it; less often, the assistant’s provider did not answer in time.
What you see
Section titled “What you see”In a query tab, the result bar reads Failed or Failed on line and a line number, and the result area shows the message from Postgres:
canceling statement due to statement timeout
In the assistant pane, or under Test connection in Settings, under AI Assistant:
The provider took too long to answer.
Why it happens
Section titled “Why it happens”A statement ran past the time limit
Section titled “A statement ran past the time limit”Alcuin sets Postgres’ statement_timeout for each connection from two settings:
- Stop statements after, in Settings, under Safety, for each environment. Production starts at 30 seconds.
- Stop queries after, in the connection’s settings: Never, 10 seconds, 30 seconds, 2 minutes or 10 minutes.
The shorter of the two applies.
When neither sets a limit, any statement_timeout your role or database has on the server applies.
The provider did not answer
Section titled “The provider did not answer”The assistant waits up to five minutes for its provider. A slow model, a busy provider or a large request can take longer.
What to do
Section titled “What to do”For a statement
Section titled “For a statement”- Make the statement do less: add a
LIMIT, filter on an indexed column, or select fewer columns. - Click Explain without Analyze to see the plan without running the statement, and look for sequential scans of large tables.
- If the statement needs longer, raise whichever limit is shorter: Stop queries after in the connection’s settings, or Stop statements after in Settings, under Safety. Both are read when the connection opens, so reconnect afterward. Production’s limit in Settings can only be made shorter.
Two failures look similar but are not this code:
- A statement that gives up waiting for a lock fails with Postgres’ own message,
canceling statement due to lock timeout. That limit is Give up waiting for a lock after, in Settings, under Safety. - A statement that another client, an administrator or
pg_cancel_backend()canceled fails withcanceling statement due to user requestand the SQLSTATE57014. Find out who cancelled it: Activity shows the sessions on the server.
If the server reports its messages in another language (lc_messages), a timeout also shows as SQLSTATE 57014 in that language, because Alcuin cannot tell it from another session’s cancel.
For the assistant
Section titled “For the assistant”- Try again. A busy provider often answers the second time.
- Ask a smaller question, or leave out Include 20 result rows.
- For a model on your own machine, check that it is not overloaded.
- To check the provider and its address, see Set up a provider.
Internal name
Section titled “Internal name”The engine reports this as ENGINE_TIMEOUT. Quote either name in an issue.