{"record":{"id":"af28177ebb0a4a78","repo":"flowable/flowable-engine","slug":"couldn-t-get-table-counts","errorCode":null,"errorMessage":"couldn't get table counts","messagePattern":"couldn't get table counts","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/entity/TableDataManagerImpl.java","lineNumber":59,"sourceCode":"\n    private static final Logger LOGGER = LoggerFactory.getLogger(TableDataManagerImpl.class);\n    \n    protected AbstractEngineConfiguration engineConfiguration;\n    \n    public TableDataManagerImpl(AbstractEngineConfiguration engineConfiguration) {\n        this.engineConfiguration = engineConfiguration;\n    }\n\n    @Override\n    public Map<String, Long> getTableCount() {\n        Map<String, Long> tableCount = new HashMap<>();\n        try {\n            for (String tableName : getTablesPresentInDatabase()) {\n                tableCount.put(tableName, getTableCount(tableName));\n            }\n            LOGGER.debug(\"Number of rows per flowable table: {}\", tableCount);\n        } catch (Exception e) {\n            throw new FlowableException(\"couldn't get table counts\", e);\n        }\n        return tableCount;\n    }\n\n    @Override\n    public List<String> getTablesPresentInDatabase() {\n        List<String> tableNames = new ArrayList<>();\n        try {\n            Connection connection = getDbSqlSession().getSqlSession().getConnection();\n            DatabaseMetaData databaseMetaData = connection.getMetaData();\n            LOGGER.debug(\"retrieving flowable tables from jdbc metadata\");\n            String databaseTablePrefix = getDbSqlSession().getDbSqlSessionFactory().getDatabaseTablePrefix();\n            String actTableNameFilter = getTableNameFilter(databaseMetaData, databaseTablePrefix, \"ACT\");\n            String flwTableNameFilter = getTableNameFilter(databaseMetaData, databaseTablePrefix, \"FLW\");\n\n            String catalog = getDatabaseCatalog();\n\n            String schema = getDatabaseSchema();","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/entity/TableDataManagerImpl.java#L41-L77","documentation":"Flowable wraps any failure while counting rows in its database tables into this FlowableException. getTableCount() iterates all tables present in the database and counts rows per table; if any per-table count query (or listing the tables) fails, the original exception is rethrown with this message.","triggerScenarios":"Calling ManagementService.getTableCount() (directly or via engine startup schema checks) when the underlying table count SQL fails: table dropped mid-check, insufficient SELECT privileges, broken connection, or getTablesPresentInDatabase() failing.","commonSituations":"Database user lacks SELECT permission on Flowable tables; database connection lost or timed out during engine initialization; schema partially dropped/corrupted; unsupported database dialect producing bad metadata queries.","solutions":["Check the wrapped cause exception for the root SQL error (connection, permission, or missing table)","Grant the DB user SELECT privileges on all Flowable ACT_/FLW_ tables","Verify database connectivity and that the engine schema exists (run databaseSchemaUpdate or the schema scripts)","Confirm the configured databaseType matches the actual database"],"exampleFix":"// before\nlong count = managementService.getTableCount();\n// after\ntry {\n    long count = managementService.getTableCount();\n} catch (FlowableException e) {\n    LOGGER.error(\"table count failed; cause=\" + e.getCause(), e);\n}","handlingStrategy":"try-catch","validationCode":"// ensure connectivity & permissions first\ntry (Connection c = dataSource.getConnection()) {\n    DatabaseMetaData md = c.getMetaData();\n    ResultSet rs = md.getTables(null, schema, \"ACT_RU_TASK\", null);\n    if (!rs.next()) throw new IllegalStateException(\"Flowable schema missing\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    long count = managementService.getTableCount();\n} catch (FlowableException e) {\n    LOGGER.error(\"Table count failed: {}\", e.getCause() != null ? e.getCause().getMessage() : e.getMessage(), e);\n}","preventionTips":["Grant SELECT on all ACT_/FLW_ tables to the engine's DB user","Validate DB connectivity at startup before engine init","Keep the configured databaseType in sync with the actual database"],"tags":["database","persistence","schema-check"],"backgroundTag":"database-query-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}