{"record":{"id":"ed89de3314786cb1","repo":"iflytek/astron-agent","slug":"database-count-limited","errorCode":"DATABASE_COUNT_LIMITED","errorMessage":"DATABASE_COUNT_LIMITED","messagePattern":"DATABASE_COUNT_LIMITED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java","lineNumber":285,"sourceCode":"            log.error(\"Failed to query database list, params={}\", JSONObject.toJSONString(databaseDto), ex);\n            throw new BusinessException(ResponseEnum.DATABASE_QUERY_FAILED);\n        }\n    }\n\n    @Transactional\n    public void createDbTable(DbTableDto dbTableDto) {\n        dataPermissionCheckTool.checkDbBelong(dbTableDto.getDbId());\n        try {\n            DbInfo dbInfo = dbInfoMapper.selectById(dbTableDto.getDbId());\n            if (dbInfo == null) {\n                throw new BusinessException(ResponseEnum.DATABASE_NOT_EXIST);\n            }\n            // Table count limit\n            Long tableCount = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()\n                    .eq(DbTable::getDbId, dbInfo.getDbId())\n                    .eq(DbTable::getDeleted, false));\n            if (tableCount > 20) {\n                throw new BusinessException(ResponseEnum.DATABASE_COUNT_LIMITED);\n            }\n            // Duplicate table name validation\n            Long count = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()\n                    .eq(DbTable::getName, dbTableDto.getName())\n                    .eq(DbTable::getDbId, dbInfo.getDbId())\n                    .eq(DbTable::getDeleted, false));\n            if (count > 0) {\n                throw new BusinessException(ResponseEnum.DATABASE_TABLE_NAME_EXIST);\n            }\n            // Build DDL statement and validate required system fields\n            if (dbTableDto.getFields() == null || dbTableDto.getFields().isEmpty()) {\n                throw new BusinessException(ResponseEnum.DATABASE_TABLE_FIELD_CANNOT_EMPTY);\n            }\n            // Table fields cannot exceed 20\n            if (dbTableDto.getFields().size() > 20) {\n                throw new BusinessException(ResponseEnum.DATABASE_FIELD_CANNOT_BEYOND_20);\n            }\n            // Save information","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java#L267-L303","documentation":"Thrown by DatabaseService.createDbTable when the target database already contains more than 20 non-deleted tables (tableCount > 20). This is a platform quota that caps tables per database to keep the underlying storage manageable. It is deterministic and will recur until tables are removed or the quota is raised.","triggerScenarios":"Creating a 22nd+ table in one database: any call to createDbTable when the count of non-deleted DbTable rows for the db exceeds 20.","commonSituations":"Long-lived databases accumulating test tables; migration scripts bulk-creating tables; users hitting the cap during experiments and not cleaning up old tables.","solutions":["Delete unused tables in the database to free quota, then retry","Distribute tables across multiple databases","Increase the hard-coded limit (tableCount > 20) if the platform policy allows","Archive/export old table data before dropping tables"],"exampleFix":"// before\n// hard-coded quota in DatabaseService\nif (tableCount > 20) { throw new BusinessException(ResponseEnum.DATABASE_COUNT_LIMITED); }\n// after\n// make the limit configurable\n@Value(\"${db.table.count.limit:20}\")\nprivate int tableCountLimit;\nif (tableCount > tableCountLimit) { throw new BusinessException(ResponseEnum.DATABASE_COUNT_LIMITED); }","handlingStrategy":"validation","validationCode":"long tableCount = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()\n    .eq(DbTable::getDbId, dbId).eq(DbTable::getDeleted, false));\nif (tableCount >= 20) { /* free quota or use another database */ }","typeGuard":null,"tryCatchPattern":"try { databaseService.createDbTable(dto); } catch (BusinessException e) { if (\"DATABASE_COUNT_LIMITED\".equals(e.getCode())) { /* prompt user to delete tables or switch database */ } else { throw e; } }","preventionTips":["Show table-count usage in the UI before create","Periodically clean up unused/test tables","Keep table-count checks inline with the configured quota"],"tags":["quota","limit","database","java"],"backgroundTag":"quota-exceeded","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}