{"record":{"id":"4cccf98d16ce588e","repo":"iflytek/astron-agent","slug":"database-copy-failed","errorCode":"DATABASE_COPY_FAILED","errorMessage":"DATABASE_COPY_FAILED","messagePattern":"DATABASE_COPY_FAILED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java","lineNumber":231,"sourceCode":"                        dbTableFieldMapper.selectList(new QueryWrapper<DbTableField>().lambda()\n                                .eq(DbTableField::getTbId, dbTable.getId())).forEach(dbTableField -> {\n                                    DbTableField newDbTableField = new DbTableField();\n                                    BeanUtils.copyProperties(dbTableField, newDbTableField);\n                                    newDbTableField.setTbId(newDbTable.getId());\n                                    newDbTableField.setId(null);\n                                    newDbTableField.setCreateTime(new Date());\n                                    newDbTableField.setUpdateTime(new Date());\n                                    fields.add(newDbTableField);\n                                });\n                        dbTableFieldMapper.insertBatch(fields);\n                    });\n            // Call core system to create database\n            Long dbId = coreSystemService.cloneDataBase(dbInfo.getDbId(), newDbInfo.getName(), UserInfoManagerHandler.getUserId());\n            newDbInfo.setDbId(dbId);\n            dbInfoMapper.updateById(newDbInfo);\n        } catch (Exception ex) {\n            log.error(\"copy database failed,dbId={}\", id, ex);\n            throw new BusinessException(ResponseEnum.DATABASE_COPY_FAILED);\n        }\n\n    }\n\n\n    public void addFlowRel(String dbId, String tbName, String flowId) {\n        DbTable dbTable = dbTableMapper.selectByDbId(dbId, tbName);\n        FlowDbRel flowDbRel = new FlowDbRel();\n        flowDbRel.setFlowId(flowId);\n        flowDbRel.setDbId(dbId);\n        flowDbRel.setTbId(dbTable.getId());\n        flowDbRel.setCreateTime(new Date());\n        flowDbRelMapper.insert(flowDbRel);\n    }\n\n    public Page<DbInfo> selectPage(DataBaseSearchVo databaseDto) {\n        try {\n            Long spaceId = SpaceInfoUtil.getSpaceId();","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java#L213-L249","documentation":"Catch-all in DatabaseService.copyDatabase: any failure while loading the source database, generating the copy name, calling coreSystemService.cloneDataBase, or persisting the new record is converted to DATABASE_COPY_FAILED. The log 'copy database failed,dbId=' contains the underlying stack trace.","triggerScenarios":"Source id does not exist or user lacks permission; coreSystemService.cloneDataBase RPC fails or times out; dbInfoMapper.updateById fails after clone; duplicate resulting name violates uniqueness downstream.","commonSituations":"Core service degraded/unreachable during clone; cloning a database concurrently from two tabs; source database was deleted between listing and copying.","solutions":["Check the logged stack trace for the root cause","Verify the source dbId still exists and the user has access","Retry the copy if the core-system call failed transiently","Ensure the target name (copy name) is unique in the space"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"DbInfo src = dbInfoMapper.selectById(id);\nif (src == null || Boolean.TRUE.equals(src.getDeleted())) { throw new IllegalStateException(\"source db missing\"); }","typeGuard":null,"tryCatchPattern":"try { databaseService.copyDatabase(id); } catch (BusinessException e) { if (\"DATABASE_COPY_FAILED\".equals(e.getCode())) { /* check core-system health, retry with backoff */ } else { throw e; } }","preventionTips":["Health-check the core system before large clone operations","Avoid concurrent copies of the same source database","Ensure the generated copy name is unique in the space"],"tags":["database","copy","upstream","internal-error","java"],"backgroundTag":"api-request-failed","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"}