iflytek/astron-agent · warning · BusinessException

DATABASE_COUNT_LIMITED

DATABASE_COUNT_LIMITED

Error message

DATABASE_COUNT_LIMITED

What it means

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.

Solutions

  1. Delete unused tables in the database to free quota, then retry
  2. Distribute tables across multiple databases
  3. Increase the hard-coded limit (tableCount > 20) if the platform policy allows
  4. Archive/export old table data before dropping tables

Example fix

// before
// hard-coded quota in DatabaseService
if (tableCount > 20) { throw new BusinessException(ResponseEnum.DATABASE_COUNT_LIMITED); }
// after
// make the limit configurable
@Value("${db.table.count.limit:20}")
private int tableCountLimit;
if (tableCount > tableCountLimit) { throw new BusinessException(ResponseEnum.DATABASE_COUNT_LIMITED); }
Defensive patterns

Strategy: validation

Validate before calling

long tableCount = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()
    .eq(DbTable::getDbId, dbId).eq(DbTable::getDeleted, false));
if (tableCount >= 20) { /* free quota or use another database */ }

Try / catch

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; } }

Prevention

When it happens

Trigger: Creating a 22nd+ table in one database: any call to createDbTable when the count of non-deleted DbTable rows for the db exceeds 20.

Common situations: Long-lived databases accumulating test tables; migration scripts bulk-creating tables; users hitting the cap during experiments and not cleaning up old tables.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/ed89de3314786cb1. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java:285

            log.error("Failed to query database list, params={}", JSONObject.toJSONString(databaseDto), ex);
            throw new BusinessException(ResponseEnum.DATABASE_QUERY_FAILED);
        }
    }

    @Transactional
    public void createDbTable(DbTableDto dbTableDto) {
        dataPermissionCheckTool.checkDbBelong(dbTableDto.getDbId());
        try {
            DbInfo dbInfo = dbInfoMapper.selectById(dbTableDto.getDbId());
            if (dbInfo == null) {
                throw new BusinessException(ResponseEnum.DATABASE_NOT_EXIST);
            }
            // Table count limit
            Long tableCount = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()
                    .eq(DbTable::getDbId, dbInfo.getDbId())
                    .eq(DbTable::getDeleted, false));
            if (tableCount > 20) {
                throw new BusinessException(ResponseEnum.DATABASE_COUNT_LIMITED);
            }
            // Duplicate table name validation
            Long count = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()
                    .eq(DbTable::getName, dbTableDto.getName())
                    .eq(DbTable::getDbId, dbInfo.getDbId())
                    .eq(DbTable::getDeleted, false));
            if (count > 0) {
                throw new BusinessException(ResponseEnum.DATABASE_TABLE_NAME_EXIST);
            }
            // Build DDL statement and validate required system fields
            if (dbTableDto.getFields() == null || dbTableDto.getFields().isEmpty()) {
                throw new BusinessException(ResponseEnum.DATABASE_TABLE_FIELD_CANNOT_EMPTY);
            }
            // Table fields cannot exceed 20
            if (dbTableDto.getFields().size() > 20) {
                throw new BusinessException(ResponseEnum.DATABASE_FIELD_CANNOT_BEYOND_20);
            }
            // Save information

View on GitHub (pinned to 5e758547a8)