{"record":{"id":"1af227f4a6339edd","repo":"apache/shardingsphere","slug":"unsupported-postgresql-version-s","errorCode":null,"errorMessage":"Unsupported PostgreSQL version: %s","messagePattern":"Unsupported PostgreSQL version: (.+?)","errorType":"exception","errorClass":"PipelineInternalException","httpStatus":null,"severity":"error","filePath":"kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/wal/position/PostgreSQLIncrementalPositionManager.java","lineNumber":70,"sourceCode":"    }\n    \n    private WALPosition getWALPosition(final Connection connection, final String logSequenceNumberSQL) throws SQLException {\n        try (\n                PreparedStatement preparedStatement = connection.prepareStatement(logSequenceNumberSQL);\n                ResultSet resultSet = preparedStatement.executeQuery()) {\n            resultSet.next();\n            return new WALPosition(new PostgreSQLLogSequenceNumber(LogSequenceNumber.valueOf(resultSet.getString(1))));\n        }\n    }\n    \n    private String getLogSequenceNumberSQL(final DatabaseMetaData metaData) throws SQLException {\n        if (9 == metaData.getDatabaseMajorVersion() && 6 <= metaData.getDatabaseMinorVersion()) {\n            return \"SELECT PG_CURRENT_XLOG_LOCATION()\";\n        }\n        if (10 <= metaData.getDatabaseMajorVersion()) {\n            return \"SELECT PG_CURRENT_WAL_LSN()\";\n        }\n        throw new PipelineInternalException(\"Unsupported PostgreSQL version: \" + metaData.getDatabaseProductVersion());\n    }\n    \n    @Override\n    public void destroy(final DataSource dataSource, final String slotNameSuffix) throws SQLException {\n        try (Connection connection = dataSource.getConnection()) {\n            slotManager.dropIfExisted(connection, slotNameSuffix);\n        }\n    }\n    \n    @Override\n    public String getDatabaseType() {\n        return \"PostgreSQL\";\n    }\n}\n","sourceCodeStart":52,"sourceCodeEnd":85,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/wal/position/PostgreSQLIncrementalPositionManager.java#L52-L85","documentation":"The PostgreSQL incremental position manager needs the current WAL LSN to seed incremental ingestion. It picks a SQL function by server version: PG_CURRENT_XLOG_LOCATION for 9.6 and PG_CURRENT_WAL_LSN for 10+. Any older server (or a version metadata report it cannot classify) triggers a PipelineInternalException naming the exact product version string.","triggerScenarios":"Calling getPosition(...) on a PostgreSQL connection whose DatabaseMetaData reports major version < 9, or 9 with minor < 6. Typically happens at migration/CDC job start when the position manager opens a connection and queries metadata before choosing the LSN function.","commonSituations":"Pointing a migration or CDC source at PostgreSQL 9.5 or older (or a very old Greenplum/compatible fork reporting old version numbers); misrouted connection that lands on an unexpected database; product version strings from proxies that confuse metadata.","solutions":["Use PostgreSQL 9.6+ (ideally 10+) as the pipeline source; upgrade the source server.","Verify the actual server behind the JDBC URL with SELECT version(); a proxy or pgbouncer routing may point at an older instance than intended.","If stuck on an old version in a fork, extend getLogSequenceNumberSQL to handle its version and LSN function, but this requires a code change and is unsupported upstream."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"try (Connection conn = dataSource.getConnection()) {\n    DatabaseMetaData md = conn.getMetaData();\n    int major = md.getDatabaseMajorVersion(), minor = md.getDatabaseMinorVersion();\n    if (major < 9 || (9 == major && minor < 6)) {\n        throw new IllegalStateException(\"PostgreSQL 9.6+ required, got \" + md.getDatabaseProductVersion());\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    position = positionManager.getPosition(dataSource);\n} catch (final PipelineInternalException ex) {\n    // surface version string and abort job setup before slot creation\n    throw ex;\n}","preventionTips":["Assert source PostgreSQL version >= 9.6 in deployment checks.","Verify SELECT version() on the exact host the JDBC URL resolves to.","Beware connection routers/proxies that change which server is reached."],"tags":["postgresql","version","wal","lsn","data-pipeline"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}