{"record":{"id":"6501a9248d1068d1","repo":"apache/dolphinscheduler","slug":"unable-to-determine-current-software-version-so-c","errorCode":null,"errorMessage":"Unable to determine current software version, so cannot upgrade","messagePattern":"Unable to determine current software version, so cannot upgrade","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/DolphinSchedulerManager.java","lineNumber":95,"sourceCode":"\n    public void initDolphinSchedulerSchema() {\n        log.info(\"Start initializing the DolphinScheduler manager table structure\");\n        upgradeDao.initSchema();\n    }\n\n    public void upgradeDolphinScheduler() throws IOException {\n        // Gets a list of all upgrades\n        List<String> schemaList = SchemaUtils.getAllSchemaList();\n        if (schemaList == null || schemaList.isEmpty()) {\n            log.info(\"There is no schema to upgrade!\");\n        } else {\n            String version;\n            // Get the version of the current system\n            if (databaseDialect.tableExists(\"t_ds_version\")) {\n                version = upgradeDao.getCurrentVersion(\"t_ds_version\");\n            } else {\n                log.error(\"Unable to determine current software version, so cannot upgrade\");\n                throw new RuntimeException(\"Unable to determine current software version, so cannot upgrade\");\n            }\n            // The target version of the upgrade\n            String schemaVersion;\n            for (String schemaDir : schemaList) {\n                schemaVersion = schemaDir.split(\"_\")[0];\n                if (SchemaUtils.isAGreatVersion(schemaVersion, version)) {\n                    log.info(\"upgrade DolphinScheduler metadata version from {} to {}\", version, schemaVersion);\n                    log.info(\"Begin upgrading DolphinScheduler's table structure\");\n                    upgradeDao.upgradeDolphinScheduler(schemaDir);\n                    DolphinSchedulerVersion.getVersion(schemaVersion).ifPresent(v -> upgraderMap.get(v).doUpgrade());\n                    version = schemaVersion;\n                }\n            }\n        }\n\n        // Assign the value of the version field in the version table to the version of the product\n        upgradeDao.updateVersion(SchemaUtils.getSoftVersion());\n    }","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/DolphinSchedulerManager.java#L77-L113","documentation":"DolphinSchedulerManager.upgradeDolphinScheduler throws this RuntimeException when the target database has no t_ds_version table, so the currently installed schema version cannot be read. The upgrade tool refuses to proceed rather than guessing the schema version, because upgrade scripts depend on knowing the starting version.","triggerScenarios":"Running the upgrade (tools/datasource upgrade) against a database where the t_ds_version table does not exist — typically a fresh/empty database, a database initialized by a very old version, or connecting to the wrong database/schema.","commonSituations":"Pointing the upgrade tool at an empty database instead of the existing production DB; pointing at the wrong database name or host; running upgrade before ever running init-schema; version table dropped manually.","solutions":["Confirm you are connected to the correct existing DolphinScheduler database that was previously initialized (check JDBC URL in the tool's datasource config).","If the DB is fresh, run the init-schema command instead of upgrade.","Check the database manually: SELECT * FROM t_ds_version; if missing, determine the actual schema version from table shapes and insert a version row before upgrading.","Verify the user account can see the table (schema/catalog visibility on PostgreSQL/Oracle)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// check before running the upgrade tool\njava.sql.DatabaseMetaData md = connection.getMetaData();\ntry (java.sql.ResultSet rs = md.getTables(null, null, \"t_ds_version\", null)) {\n    if (!rs.next()) throw new IllegalStateException(\"t_ds_version missing: run init-schema or check you target the right DB\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    manager.upgradeDolphinScheduler();\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"Unable to determine current software version\")) {\n        log.error(\"Target DB has no t_ds_version table - verify JDBC URL or run init-schema\", e);\n    } else { throw e; }\n}","preventionTips":["Always init-schema before ever running upgrade.","Double-check the upgrade tool's JDBC URL points at the production DB.","Snapshot/backup the DB before upgrading.","Confirm the DB user can see t_ds_version (schema/search_path)."],"tags":["database","upgrade","version-table"],"backgroundTag":"entity-not-found","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}