iflytek/astron-agent · error · BusinessException

8522

8522

Error message

database.table.copy.failed

What it means

Thrown by DatabaseService.copyTable when copying a table (its metadata row and field rows) fails. Code 8522, message 'database.table.copy.failed'. The method is @Transactional, so any exception here rolls back the partial copy; this error reports the wrapped cause.

Solutions

  1. Check log 'copy table failed, tbId=...' for the root-cause stack trace.
  2. If duplicate-name, retry — a new name is typically generated per attempt.
  3. Verify DB health and connection pool capacity; large batches may need splitting.
  4. Because the method is transactional, confirm no partial rows remain; re-run the copy after fixing the cause.

Example fix

// before
dbTableFieldMapper.insertBatch(copyTableFields); // one huge batch can exceed limits
// after
for (List<DbTableField> chunk : Lists.partition(copyTableFields, 500)) {
    dbTableFieldMapper.insertBatch(chunk);
}
Defensive patterns

Strategy: try-catch

Validate before calling

Long exists = dbTableMapper.selectCount(new LambdaQueryWrapper<DbTable>().eq(DbTable::getTbId, tbId));
if (exists == 0) throw new IllegalStateException("source table missing: " + tbId);

Try / catch

try {
    databaseService.copyTable(tbId);
} catch (BusinessException ex) {
    if ("database.table.copy.failed".equals(ex.getMessage())) {
        log.error("copy failed and rolled back; check duplicate names / DB health", ex);
    }
    throw ex;
}

Prevention

When it happens

Trigger: Calling copyTable(tbId) when the source table lookup fails, the insert of the copied DbTable row fails (duplicate generated name, DB down), or insertBatch of the copied fields fails (e.g. batch too large, constraint violation).

Common situations: Many rapid copies hitting a unique-name constraint; connection pool exhaustion mid-transaction; field batch exceeding DB packet limits.

Related errors


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

Appendix: source

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

            copyTable.setCreateTime(new Date());
            copyTable.setUpdateTime(new Date());
            dbTableMapper.insert(copyTable);

            List<DbTableField> dbTableFields = dbTableFieldMapper.selectList(new QueryWrapper<DbTableField>().lambda()
                    .eq(DbTableField::getTbId, tbId));
            List<DbTableField> copyTableFields = new ArrayList<>();
            for (DbTableField dbTableField : dbTableFields) {
                DbTableField copyTableField = new DbTableField();
                BeanUtils.copyProperties(dbTableField, copyTableField);
                copyTableField.setTbId(copyTable.getId());
                copyTableField.setCreateTime(new Date());
                copyTableField.setUpdateTime(new Date());
                copyTableFields.add(copyTableField);
            }
            dbTableFieldMapper.insertBatch(copyTableFields);
        } catch (Exception ex) {
            log.error("copy table failed, tbId={}", tbId, ex);
            throw new BusinessException(ResponseEnum.DATABASE_TABLE_COPY_FAILED);
        }
    }

    public void exportTableData(DatabaseExportDto dto, HttpServletResponse response) {
        dataPermissionCheckTool.checkTbBelong(dto.getTbId());
        try {
            DbTable dbTable = dbTableMapper.selectById(dto.getTbId());
            DbInfo dbInfo = dbInfoMapper.selectById(dbTable.getDbId());

            String table = dialect.quoteIdent(dbTable.getName());
            String dml = "SELECT * FROM " + table + " LIMIT 1000 OFFSET 0";

            if (dto.getDataIds() != null && !dto.getDataIds().isEmpty()) {
                if (dto.getDataIds().size() > MAX_EXPORT_IDS) {
                    throw new BusinessException(ResponseEnum.DATABASE_TOO_MANY_EXPORT_IDS);
                }
                // All perform digital whitelist verification
                List<Long> ids = dto.getDataIds()

View on GitHub (pinned to 5e758547a8)