apache/dolphinscheduler · error · RuntimeException
Get current version from database error, sql: " + sql
Error message
Get current version from database error, sql: " + sql
What it means
UpgradeDao.getCurrentVersion runs 'select version from <versionName>' (t_ds_version) to read the installed schema version. A SQLException during that query is rethrown as RuntimeException 'Get current version from database error, sql: <sql>'. It means the version lookup query itself failed against the database.
Source
Thrown at dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/upgrader/UpgradeDao.java:83
} catch (Exception ex) {
throw new RuntimeException("Execute initialize sql file: " + sqlFilePath + " error", ex);
}
}
public String getCurrentVersion(String versionName) {
String sql = String.format("select version from %s", versionName);
String version = null;
try (
Connection conn = dataSource.getConnection();
PreparedStatement pstmt = conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery()) {
if (rs.next()) {
version = rs.getString(1);
}
return version;
} catch (SQLException e) {
log.error("Get current version from database error, sql: {}", sql, e);
throw new RuntimeException("Get current version from database error, sql: " + sql, e);
}
}
public void upgradeDolphinScheduler(String schemaDir) {
upgradeDolphinSchedulerDDL(schemaDir, "dolphinscheduler_ddl.sql");
upgradeDolphinSchedulerDML(schemaDir, "dolphinscheduler_dml.sql");
}
private void upgradeDolphinSchedulerDML(String schemaDir, String scriptFile) {
String schemaVersion = schemaDir.split("_")[0];
String sqlFilePath =
String.format("sql/upgrade/%s/%s/%s", schemaDir, dbType.getDb(), scriptFile);
try {
// Execute the upgraded dolphinscheduler dml
SqlScriptRunner sqlScriptRunner = new SqlScriptRunner(dataSource, sqlFilePath);
sqlScriptRunner.execute();
try (Connection connection = dataSource.getConnection()) {
String upgradeSQL;View on GitHub (pinned to 02eac45a1b)
Solutions
- Grant SELECT on t_ds_version to the database user used by the upgrade tool.
- Test the exact SQL manually with the same JDBC user: SELECT version FROM t_ds_version;
- Check DB connectivity (connection pool/timeout settings) and re-run the upgrade.
- Inspect the cause SQLException for the vendor error code to pinpoint permissions vs connection issues.
Defensive patterns
Strategy: retry
Validate before calling
// pre-check with the same connection/user
try (PreparedStatement ps = conn.prepareStatement("select version from t_ds_version");
ResultSet rs = ps.executeQuery()) {
if (!rs.next()) log.warn("t_ds_version has no rows");
} Try / catch
try {
String v = upgradeDao.getCurrentVersion("t_ds_version");
} catch (RuntimeException e) {
if (e.getCause() instanceof SQLException) {
log.error("Version query failed (check privileges/connection): {}", e.getCause().getMessage());
// retry once after reconnect
} else throw e;
} Prevention
- Grant SELECT on t_ds_version to the tool's DB user.
- Use a connection pool with keepalive/validity checks for long upgrades.
- Run the tool on the same network/host as the DB to reduce dropouts.
- Confirm default schema/search_path includes the DolphinScheduler tables.
When it happens
Trigger: Calling getCurrentVersion when the query throws SQLException: the t_ds_version table exists check passed but the query still fails due to permissions, connection drop, wrong catalog/schema, or a driver issue.
Common situations: Insufficient SELECT privilege on the version table; stale/dropped connection to the DB during a long upgrade; connecting with a user whose default schema differs from the one holding t_ds_version.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- Execute initialize sql file: " + sqlFilePath + " error
- Execute ddl file failed, meet an unknown exception
- Upgrade version error, sql:
- Query t_ds_process_instance error
- Query t_ds_user error
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/d559d9b39f742c0f.
Report an issue: GitHub.