{"record":{"id":"d77bf46011e0f776","repo":"apache/seatunnel","slug":"delete-response-status-code-body-for-scr","errorCode":null,"errorMessage":"DELETE {} response status code={}, body={} for scroll ID: {}","messagePattern":"DELETE (.+?) response status code=(.+?), body=(.+?) for scroll ID: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/client/EsRestClient.java","lineNumber":335,"sourceCode":"        Request request = new Request(\"DELETE\", endpoint);\n        Map<String, String> requestBody = new HashMap<>();\n        requestBody.put(\"scroll_id\", scrollId);\n        request.setJsonEntity(JsonUtils.toJsonString(requestBody));\n\n        try {\n            Response response = restClient.performRequest(request);\n            if (response == null) {\n                log.warn(\"DELETE {} response null for scroll ID: {}\", endpoint, scrollId);\n                return false;\n            }\n            String entity = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);\n            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {\n                JsonNode jsonNode = JsonUtils.parseObject(entity);\n                boolean succeeded = jsonNode.get(\"succeeded\").asBoolean();\n                return succeeded;\n            } else {\n                log.warn(\n                        \"DELETE {} response status code={}, body={} for scroll ID: {}\",\n                        endpoint,\n                        response.getStatusLine().getStatusCode(),\n                        entity,\n                        scrollId);\n                return false;\n            }\n        } catch (Exception ex) {\n            log.warn(\"Failed to clear scroll ID: \" + scrollId, ex);\n            return false;\n        }\n    }\n\n    /**\n     * Close SQL cursor to release server-side resources.\n     *\n     * @param cursor The SQL cursor to close\n     * @return True if the cursor was successfully closed\n     */","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/client/EsRestClient.java#L317-L353","documentation":"clearScroll received a real HTTP response but with a non-200 status; it logs endpoint, status code, response body and scroll ID, and returns false. Elasticsearch rejected the DELETE /_search/scroll call — e.g. 404 for an unknown/expired scroll ID, 400 malformed request, or auth failure (401/403). Note that clearing an already-expired scroll returning 404 is normally harmless.","triggerScenarios":"DELETE /_search/scroll returns 404 (scroll already expired or cleared), 401/403 (bad credentials/permissions), 400 (malformed scroll_id/body), 5xx (cluster error).","commonSituations":"Scroll TTL elapsed before cleanup ran; same scroll cleared twice (double cleanup in finally + close); user lacking privileges to clear scrolls; cluster restart losing scroll context.","solutions":["Ignore 404 for expired scrolls — treat as successful cleanup; ensure search scroll timeout is long enough for the read to finish","Check credentials/roles if status is 401/403: the user needs privileges for the _search/scroll endpoint","Deduplicate cleanup so each scroll ID is cleared exactly once","Inspect the logged response body for the exact ES error (root_cause) to disambiguate","Retry on transient 5xx with short backoff"],"exampleFix":"// before: treat any false as failure\nif (!esClient.clearScroll(scrollId)) { throw new RuntimeException(\"cleanup failed\"); }\n// after: best-effort cleanup\nboolean cleared = esClient.clearScroll(scrollId);\nif (!cleared) {\n    log.info(\"Scroll {} not cleared (likely expired); it will time out server-side\", scrollId);\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// distinguish expected 404 (expired) from real failures via the logged body\nif (!esClient.clearScroll(scrollId)) {\n    log.debug(\"Scroll {} not cleared; likely expired (harmless) or permission issue\", scrollId);\n}","preventionTips":["Ensure the ES user has privileges on _search/scroll","Set scroll TTL longer than the slowest expected read","Clear each scroll ID exactly once (track opened IDs)","Read the logged status/body to classify 404 vs 401/403 vs 5xx"],"tags":["elasticsearch","scroll","http-status","cleanup"],"backgroundTag":"http-error-response","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}