Skip to content

Clear error state before logging prewarm cancellation#12907

Open
mingjiegao wants to merge 1 commit into
neondatabase:mainfrom
mingjiegao:fix-file-cache-error-state
Open

Clear error state before logging prewarm cancellation#12907
mingjiegao wants to merge 1 commit into
neondatabase:mainfrom
mingjiegao:fix-file-cache-error-state

Conversation

@mingjiegao

Copy link
Copy Markdown

Problem

In pgxn/neon/file_cache.c, the prewarm cancellation path can enter PG_CATCH() when WaitForBackgroundWorkerShutdown() is interrupted, for example because of cancellation or another error.

The catch block currently calls elog(LOG, ...) before clearing the active error state. PostgreSQL keeps the backend in the error handling context until FlushErrorState() is called. If this path is hit repeatedly, the error data stack can keep growing. After 5 entries (ERRORDATA_STACK_SIZE = 5), PostgreSQL can raise:

ereport(PANIC, (errmsg_internal("ERRORDATA_STACK_SIZE exceeded")));

Summary of changes

Call FlushErrorState() before elog(LOG, "LFC: cancel prewarm") in the PG_CATCH() block, so the previous error state is cleared before the catch path calls back into PostgreSQL's error reporting machinery.

@mingjiegao mingjiegao requested review from a team as code owners June 4, 2026 06:32
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.

1 participant