Does jdbc_paging_enabled prevent JVM heap exhaustion when the JDBC driver lacks cursor support?
0 reputation · 30 Nov 2023, 20:02 UTC
0 reputation · 30 Nov 2023, 20:02 UTC
When ingesting large datasets via the Logstash JDBC input plugin, the jdbc_paging_enabled setting is used to fetch results in smaller chunks rather than loading the entire result set into memory.
However, the effectiveness of this feature depends on the underlying JDBC driver's ability to support cursor-based fetching. In environments where the driver does not support this mechanism, there is uncertainty regarding whether Logstash can still bound the memory footprint or if it reverts to a full result set load.
What is the fallback behavior of the JDBC input plugin when jdbc_paging_enabled is set to true but the driver does not support the required cursor functionality? Does this configuration lead to an OutOfMemoryError during the initial fetch of a large dataset?
35275 reputation · 01 Dec 2023, 04:00 UTC
Setting jdbc_paging_enabled to true does not cause an OutOfMemoryError when the underlying JDBC driver lacks cursor support. The Logstash JDBC input plugin will either paginate successfully using LIMIT/OFFSET clauses (based on the detected database dialect) or fail with a clear SQL exception; it does not fall back to loading the entire result set into memory.
The plugin builds queries with LIMIT and OFFSET (or the dialect‑specific equivalent) when jdbc_paging_enabled is true. If the driver or dialect does not support those clauses, the JDBC call throws an SQLSyntaxError or similar exception, and the plugin aborts the fetch rather than attempting to retrieve all rows.
jdbc_paging_enabled is true, Logstash generates LIMIT/OFFSET‑based queries regardless of cursor support.jdbc_paging_enabled and set a modest jdbc_page_size (e.g., 1000).jstat, VisualGC, or similar). Heap should stay bounded during execution.SQLSyntaxError or JDBCException indicating unsupported LIMIT/OFFSET; absence of such errors confirms pagination is working.jdbc_paging_enabled and observe heap growth to contrast the behaviors.To be certain that LIMIT/OFFSET is actually supported by your JDBC driver/database combination, please confirm the driver version and the dialect Logstash detects (e.g., via Logstash startup logs). If the driver silently ignores LIMIT/OFFSET, the plugin could fetch all rows; verifying the driver’s behavior changes the recommendation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.