{"record":{"id":"4f03d7f493ce4afe","repo":"apache/seatunnel","slug":"failed-to-close-allocator","errorCode":null,"errorMessage":"Failed to close allocator: {}","messagePattern":"Failed to close allocator: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/sink/LanceSinkWriter.java","lineNumber":212,"sourceCode":"    @Override\n    public void close() throws IOException {\n        try {\n            flushBatch();\n        } finally {\n            if (dataset != null) {\n                try {\n                    dataset.close();\n                } catch (Exception e) {\n                    log.warn(\"Failed to close dataset: {}\", e.getMessage());\n                }\n                dataset = null;\n            }\n\n            if (allocator != null) {\n                try {\n                    allocator.close();\n                } catch (Exception e) {\n                    log.warn(\"Failed to close allocator: {}\", e.getMessage());\n                }\n                allocator = null;\n            }\n        }\n    }\n}\n","sourceCodeStart":194,"sourceCodeEnd":219,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/sink/LanceSinkWriter.java#L194-L219","documentation":"LanceSinkWriter.close also closes the Arrow BufferAllocator. If allocator.close() throws (typically because buffers allocated from it were not released), the writer logs this warning and nulls the reference. This usually signals a memory leak of Arrow buffers.","triggerScenarios":"Closing the sink writer while some Arrow ValueVector/ByteBuf allocated from the allocator was never released, e.g. an exception path skipped release, or allocator.close invoked while batches are still referenced.","commonSituations":"Job failure mid-flush leaving vectors un-released; custom code retaining buffers after writer.close(); Arrow reference-counting bugs in long-running pipelines.","solutions":["Ensure every ValueVector/batch allocated from the allocator is released before close","Check for exception paths in write/flushBatch that skip buffer release; wrap them in try/finally with release","Look at the logged message to identify the leaked reference count","Use Arrow's BaseAllocator DEBUG mode to find the leak stack trace"],"exampleFix":"// before\nVectorSchemaRoot root = VectorSchemaRoot.create(schema, allocator);\nroot.clear(); // missing release of underlying buffers in some path\n// after\nVectorSchemaRoot root = VectorSchemaRoot.create(schema, allocator);\ntry {\n    // write data\n} finally {\n    root.clear();\n}\nallocator.close();","handlingStrategy":"try-catch","validationCode":"// check allocator state before close\nif (allocator.getAllocatedMemory() > 0) System.out.println(\"Warning: un-released Arrow memory before close\");","typeGuard":null,"tryCatchPattern":"try { writer.close(); } catch (Exception e) { log.warn(\"Arrow allocator leak suspected: {}\", e.getMessage()); }","preventionTips":["Release every ValueVector/root allocated from the writer's allocator","Use try/finally around buffer usage","Enable Arrow allocator DEBUG accounting in dev to catch leaks early"],"tags":["lance","arrow","memory-leak","resource-cleanup"],"backgroundTag":"resource-cleanup-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}