{"record":{"id":"406182b1298f1aea","repo":"prestodb/presto","slug":"generic-internal-error-406182","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Error loading index for join","messagePattern":"Error loading index for join","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"critical","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/index/IndexLoader.java","lineNumber":358,"sourceCode":"        {\n            // Generate a RecordSet that only presents index keys that have not been cached and are deduped based on lookupSourceInputChannels\n            UnloadedIndexKeyRecordSet recordSetForLookupSource = new UnloadedIndexKeyRecordSet(pipelineContext.getSession(), indexSnapshotReference.get(), lookupSourceInputChannels, indexTypes, requests, joinCompiler);\n\n            // Drive index lookup to produce the output (landing in indexSnapshotBuilder)\n            try (Driver driver = driverFactory.createDriver(pipelineContext.addDriverContext())) {\n                PlanNodeId sourcePlanNodeId = driverFactory.getSourceId().get();\n                ScheduledSplit split = new ScheduledSplit(0, sourcePlanNodeId, new Split(INDEX_CONNECTOR_ID, new ConnectorTransactionHandle() {}, new IndexSplit(recordSetForLookupSource)));\n                driver.updateSource(new TaskSource(sourcePlanNodeId, ImmutableSet.of(split), true));\n                while (!driver.isFinished()) {\n                    ListenableFuture<?> process = driver.process();\n                    try {\n                        process.get(timeout.toMillis(), MILLISECONDS);\n                    }\n                    catch (TimeoutException e) {\n                        throw new PrestoException(INDEX_LOADER_TIMEOUT, format(\"Exceeded the time limit of %s loading indexes for index join\", timeout));\n                    }\n                    catch (ExecutionException e) {\n                        throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Error loading index for join\", e);\n                    }\n                    catch (InterruptedException e) {\n                        Thread.currentThread().interrupt();\n                        throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Error loading index for join\", e);\n                    }\n                }\n            }\n\n            if (indexSnapshotBuilder.isMemoryExceeded()) {\n                clearCachedData();\n                return false;\n            }\n\n            // Generate a RecordSet that presents unique index keys that have not been cached\n            UnloadedIndexKeyRecordSet indexKeysRecordSet = (lookupSourceInputChannels.equals(allInputChannels))\n                    ? recordSetForLookupSource\n                    : new UnloadedIndexKeyRecordSet(pipelineContext.getSession(), indexSnapshotReference.get(), allInputChannels, indexTypes, requests, joinCompiler);\n","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/index/IndexLoader.java#L340-L376","documentation":"During IndexLoader.load, if the index-building Driver's process() future completes exceptionally, the ExecutionException is rethrown as GENERIC_INTERNAL_ERROR 'Error loading index for join' with the original cause. This indicates the index build itself failed, not a timeout.","triggerScenarios":"Index join where the driver processing index source rows throws (connector error, bad data, OOM inside the driver), surfacing via process.get() ExecutionException.","commonSituations":"Connector failures while reading index source; memory pressure killing the build task; data causing exceptions in expressions evaluated during index build.","solutions":["Inspect the wrapped cause (getCause()) for the real failure","Check worker logs and memory (GC/OOM) around the failure","Add filters to reduce index source data; verify connector health","Retry the query; if persistent, fall back to a hash join"],"exampleFix":"// before\nJOIN with lookup/index join failing on connector read\n// after\nSET SESSION join_distribution_type = 'PARTITIONED'; -- force hash join fallback","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { run(sql); } catch (PrestoException e) { if (e.getErrorCode().getName().equals(\"GENERIC_INTERNAL_ERROR\") && e.getMessage().equals(\"Error loading index for join\") && e.getCause() != null) { inspectCause(e.getCause()); retryOrFallbackToHashJoin(sql); } else throw e; }","preventionTips":["Fix the root cause via e.getCause() (connector error, OOM, bad data)","Monitor worker memory to prevent OOM during index builds","Validate connector health before heavy index-join workloads","Add predicates to shrink the index source"],"tags":["presto","index-join","internal-error","connector"],"backgroundTag":"index-build-failure","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}