{"record":{"id":"9fd8c31dfc82d4ec","repo":"apache/seatunnel","slug":"create-pit-failed","errorCode":"CREATE_PIT_FAILED","errorMessage":"POST /%s/_pit?keep_alive=%dms response null","messagePattern":"POST /(.+?)/_pit\\?keep_alive=(.+?)ms response null","errorType":"error_code","errorClass":"ElasticsearchConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/client/EsRestClient.java","lineNumber":930,"sourceCode":"                            \"Failed to add field %s to index %s\", fieldTypeDefine.getName(), index),\n                    ex);\n        }\n    }\n\n    /**\n     * Creates a Point-in-Time (PIT) for the specified index.\n     *\n     * @param index The index to create a PIT for\n     * @param keepAlive The time to keep the PIT alive (in milliseconds)\n     * @return The PIT ID\n     */\n    public String createPointInTime(String index, long keepAlive) {\n        String endpoint = String.format(\"/%s/_pit?keep_alive=%dms\", index.toLowerCase(), keepAlive);\n        Request request = new Request(\"POST\", endpoint);\n        try {\n            Response response = restClient.performRequest(request);\n            if (response == null) {\n                throw new ElasticsearchConnectorException(\n                        ElasticsearchConnectorErrorCode.CREATE_PIT_FAILED,\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                JsonNode jsonNode = JsonUtils.parseObject(entity);\n                return jsonNode.get(\"id\").asText();\n            } else {\n                throw new ElasticsearchConnectorException(\n                        ElasticsearchConnectorErrorCode.CREATE_PIT_FAILED,\n                        String.format(\n                                \"POST %s response status code=%d, body=%s\",\n                                endpoint, response.getStatusLine().getStatusCode(), entity));\n            }\n        } catch (IOException ex) {\n            throw new ElasticsearchConnectorException(\n                    ElasticsearchConnectorErrorCode.CREATE_PIT_FAILED, ex);\n        }","sourceCodeStart":912,"sourceCodeEnd":948,"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#L912-L948","documentation":"createPointInTime opens a point-in-time (PIT) context (POST /{index}/_pit?keep_alive=<n>ms) used for consistent deep paging; if performRequest returns null it throws CREATE_PIT_FAILED. Without a PIT id the connector cannot perform consistent scroll/slice reads, so the read fails fast.","triggerScenarios":"POST /{index}/_pit?keep_alive=... returning null Response from performRequest instead of a Response or IOException.","commonSituations":"Custom/mock RestClient returning null; gateway/CDN in front of ES that does not route the _pit endpoint properly; transient connection drop surfaced as null in a wrapped client; very old ES versions (<7.10) where _pit is unsupported and a proxy answers oddly.","solutions":["Confirm the ES cluster is 7.10+ (PIT API requires it); for older clusters use search_after with sort or scroll instead","curl -XPOST 'es:9200/{index}/_pit?keep_alive=1m' directly to see the real behavior","Remove any proxy/CDN interference or custom client wrapper that can return null","Retry the job — transient nulls typically disappear on a healthy cluster"],"exampleFix":"// before: ES 7.9 cluster -> _pit unsupported\nPOST /idx/_pit?keep_alive=60000ms -> null/unsupported\n// after: upgrade Elasticsearch to >= 7.10, or configure the connector to read without PIT (batch/scroll mode)","handlingStrategy":"retry","validationCode":"// confirm PIT support and index presence\ncurl -s -o /dev/null -w '%{http_code}' -XPOST 'es:9200/<index>/_pit?keep_alive=1m'\n# requires Elasticsearch >= 7.10","typeGuard":"if (response == null) { throw new IOException(\"null PIT response for \" + index); }","tryCatchPattern":"try {\n    String pitId = esRestClient.createPointInTime(index, keepAlive);\n} catch (ElasticsearchConnectorException e) {\n    // retry once with backoff; verify cluster supports _pit\n}","preventionTips":["Use Elasticsearch 7.10+ when the connector relies on PIT paging","Route _pit requests directly to ES nodes, not through CDNs/edge proxies","Keep keep_alive long enough for the whole read window","Health-check the cluster before long-running consistent reads"],"tags":["elasticsearch","point-in-time","null-response","paging"],"backgroundTag":"http-request-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}