{"record":{"id":"fd3ea3962e1e1a48","repo":"iflytek/astron-agent","slug":"database-update-failed","errorCode":"DATABASE_UPDATE_FAILED","errorMessage":"DATABASE_UPDATE_FAILED","messagePattern":"DATABASE_UPDATE_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":163,"sourceCode":"        }\n    }\n\n    @Transactional\n    public void updateDateBase(DatabaseDto databaseDto) {\n        try {\n            dataPermissionCheckTool.checkDbUpdateBelong(databaseDto.getId());\n            // Name validation\n            DbInfo dbInfo = dbInfoMapper.selectById(databaseDto.getId());\n            if (StringUtils.isNotBlank(databaseDto.getDescription())) {\n                if (!databaseDto.getDescription().equals(dbInfo.getDescription())) {\n                    coreSystemService.modifyDataBase(dbInfo.getDbId(), UserInfoManagerHandler.getUserId(), databaseDto.getDescription());\n                }\n                dbInfo.setDescription(databaseDto.getDescription());\n            }\n            dbInfoMapper.updateById(dbInfo);\n        } catch (Exception ex) {\n            log.error(\"Failed to update database, params={}\", JSONObject.toJSONString(databaseDto), ex);\n            throw new BusinessException(ResponseEnum.DATABASE_UPDATE_FAILED);\n        }\n    }\n\n    public void delete(Long id) {\n        try {\n            // Check if the database is being referenced\n            dataPermissionCheckTool.checkDbUpdateBelong(id);\n            DbInfo dbInfo = dbInfoMapper.selectById(id);\n            Long count = flowDbRelMapper.selectCount(new QueryWrapper<FlowDbRel>().lambda()\n                    .eq(FlowDbRel::getDbId, dbInfo.getDbId()));\n            if (count > 0) {\n                throw new BusinessException(ResponseEnum.DATABASE_DELETE_FAILED_CITED);\n            }\n            // Delete from core system\n            coreSystemService.dropDataBase(dbInfo.getDbId(), UserInfoManagerHandler.getUserId());\n            dbInfo.setDeleted(true);\n            dbInfoMapper.updateById(dbInfo);\n        } catch (Exception ex) {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java#L145-L181","documentation":"Generic catch-all in DatabaseService.updateDateBase: any exception while loading the DbInfo, applying field changes, or calling dbInfoMapper.updateById is converted to DATABASE_UPDATE_FAILED. It hides the underlying cause (record missing, permission check failure, SQL error), so the log 'Failed to update database' must be consulted.","triggerScenarios":"Updating a database whose id does not exist; data-permission check throws; dbInfoMapper.updateById fails (lock timeout, connection error); NPE while reading fields of a null dbInfo.","commonSituations":"Two users editing the same database concurrently with optimistic/pessimistic lock conflicts; stale UI sending an id that was already deleted; DB connectivity blips.","solutions":["Read the logged stack trace for the true cause","Confirm the database id exists and is not soft-deleted before updating","Retry the update if it was a transient lock/connection error","Check the permission-check tool is not rejecting the current user/space"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"DbInfo db = dbInfoMapper.selectById(id);\nif (db == null || Boolean.TRUE.equals(db.getDeleted())) { throw new IllegalStateException(\"db not found: \" + id); }","typeGuard":null,"tryCatchPattern":"try { databaseService.updateDateBase(dto); } catch (BusinessException e) { if (\"DATABASE_UPDATE_FAILED\".equals(e.getCode())) { /* verify id exists, check logs, retry once */ } else { throw e; } }","preventionTips":["Verify the record exists and is not soft-deleted before updating","Handle concurrent-edit conflicts (refresh and reapply)","Keep permission-check failures distinct from generic update failures in logs"],"tags":["database","update","internal-error","java"],"backgroundTag":"database-write-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"}