{"record":{"id":"e0cebd19d9d223c4","repo":"apache/seatunnel","slug":"failed-to-close-sql-cursor","errorCode":null,"errorMessage":"Failed to close SQL cursor: {}","messagePattern":"Failed to close SQL cursor: (.+?)","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":385,"sourceCode":"            Response response = restClient.performRequest(request);\n            if (response == null) {\n                log.warn(\"POST {} response null for cursor: {}\", endpoint, cursor);\n                return false;\n            }\n            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {\n                String entity = EntityUtils.toString(response.getEntity());\n                JsonNode jsonNode = JsonUtils.parseObject(entity);\n                return jsonNode.get(\"succeeded\").asBoolean();\n            } else {\n                log.warn(\n                        \"POST {} response status code={} for cursor: {}\",\n                        endpoint,\n                        response.getStatusLine().getStatusCode(),\n                        cursor);\n                return false;\n            }\n        } catch (Exception ex) {\n            log.warn(\"Failed to close SQL cursor: {}\", cursor, ex);\n            return false;\n        }\n    }\n\n    private ScrollResult getDocsFromSqlResult(\n            String endpoint, String requestBody, JsonNode columnNodes) {\n        Request request = new Request(\"POST\", endpoint);\n        request.setJsonEntity(requestBody);\n        try {\n            Response response = restClient.performRequest(request);\n            if (response == null) {\n                throw new ElasticsearchConnectorException(\n                        ElasticsearchConnectorErrorCode.SCROLL_REQUEST_ERROR,\n                        \"POST \" + endpoint + \" response null\");\n            }\n            String entity = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);\n            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {\n                ObjectNode responseJson = JsonUtils.parseObject(entity);","sourceCodeStart":367,"sourceCodeEnd":403,"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#L367-L403","documentation":"In EsRestClient.closeSqlCursor, any exception thrown during the HTTP call to /_sql/close (connect timeout, socket timeout, IO error, parse failure) is caught, logged as this warning with the cursor id, and false is returned instead of propagating.","triggerScenarios":"Network failure, connection refused, request timeout, or EntityUtils/JSON processing exception while POSTing to the /_sql/close endpoint.","commonSituations":"Elasticsearch temporarily unreachable at job shutdown; firewall dropping keep-alive connections; TLS misconfiguration; large timeouts causing socket timeouts.","solutions":["Check network connectivity / proxy settings between the SeaTunnel worker and Elasticsearch","Increase http connection and socket timeout settings","Ensure TLS configuration is valid if https is used","Treat as non-fatal: the cursor expires after its keep-alive period"],"exampleFix":"// before\n// client throws/hides IO errors silently\n// after\nif (!esRestClient.closeSqlCursor(cursor)) {\n    LOG.warn(\"Cursor {} not closed cleanly; it will expire after keep-alive\", cursor);\n}","handlingStrategy":"try-catch","validationCode":"// pre-check connectivity\n// ensure ES host is reachable before job teardown relies on cursor close","typeGuard":null,"tryCatchPattern":"try { client.closeSqlCursor(cursor); } catch (Exception e) { LOG.warn(\"cursor {} will expire naturally\", cursor, e); }","preventionTips":["Configure reasonable HTTP connect/socket timeouts","Monitor network reliability to ES nodes","Don't make cursor close a hard requirement in cleanup logic"],"tags":["elasticsearch","network","exception"],"backgroundTag":"network-request-failed","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"}