prestodb/presto · error · PrestoException

GENERIC_USER_ERROR

GENERIC_USER_ERROR

Error message

Regexp matching interrupted

What it means

Internal error from getMatchingOffset: the thread performing regexp matching (searchInterruptible in regexp_extract_all/regexp_replace internals) was interrupted, typically because the query was cancelled or the coordinator timed out while a long-running regexp match was in progress.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/scalar/JoniRegexpFunctions.java:339

            offset = getMatchingOffset(matcher, nextStart, source.length());
        } while (offset != -1);

        VARCHAR.writeSlice(blockBuilder, source.slice(lastEnd, source.length() - lastEnd));
        return blockBuilder.build();
    }

    private static int getMatchingOffset(Matcher matcher, int at, int range)
    {
        return getMatchingOffset(matcher, at, range, true);
    }

    private static int getMatchingOffset(Matcher matcher, int at, int range, boolean noGroups)
    {
        try {
            return matcher.searchInterruptible(at, range, noGroups ? DONT_CAPTURE_GROUP : DEFAULT);
        }
        catch (InterruptedException interruptedException) {
            throw new PrestoException(GENERIC_USER_ERROR, "Regexp matching interrupted");
        }
    }

    private static void validateGroup(long group, Region region)
    {
        if (group < 0) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Group cannot be negative");
        }
        if (group > region.numRegs - 1) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Pattern has %d groups. Cannot access group %d", region.numRegs - 1, group));
        }
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Simplify the regexp pattern to avoid catastrophic backtracking on large inputs
  2. Reduce the size of the scanned strings (pre-filter rows)
  3. Re-run the query if it was cancelled externally
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/scalar/JoniRegexpFunctions.java:339 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/8b11a2034d7716de. Report an issue: GitHub.