{"record":{"id":"f8f6ad0db130f818","repo":"iflytek/astron-agent","slug":"notification-delete-failed","errorCode":"NOTIFICATION_DELETE_FAILED","errorMessage":"NOTIFICATION_DELETE_FAILED","messagePattern":"NOTIFICATION_DELETE_FAILED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/notification/impl/NotificationServiceImpl.java","lineNumber":135,"sourceCode":"        if (receiverUid == null || notificationId == null) {\n            throw new BusinessException(ResponseEnum.PARAMETER_ERROR);\n        }\n\n        try {\n            int deleted = notificationDataService.deleteUserNotification(receiverUid, notificationId);\n            if (deleted > 0) {\n                log.info(\"Notification deleted successfully, receiverUid: {}, notificationId: {}\",\n                        receiverUid, notificationId);\n                return true;\n            } else {\n                throw new BusinessException(ResponseEnum.NOTIFICATION_NOT_EXISTS);\n            }\n        } catch (BusinessException e) {\n            throw e; // Re-throw business exception\n        } catch (Exception e) {\n            log.error(\"Failed to delete notification, receiverUid: {}, notificationId: {}\",\n                    receiverUid, notificationId, e);\n            throw new BusinessException(ResponseEnum.NOTIFICATION_DELETE_FAILED);\n        }\n    }\n\n    // ==================== System Management ====================\n\n    @Override\n    @Transactional\n    public int cleanExpiredNotifications() {\n        try {\n            LocalDateTime expireTime = LocalDateTime.now();\n            int deleted = notificationDataService.deleteExpiredNotifications(expireTime);\n            log.info(\"Expired notifications cleaned, count: {}\", deleted);\n            return deleted;\n        } catch (Exception e) {\n            log.error(\"Failed to clean expired notifications\", e);\n            throw new BusinessException(ResponseEnum.OPERATION_FAILED);\n        }\n    }","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/notification/impl/NotificationServiceImpl.java#L117-L153","documentation":"Any non-business exception during notification deletion (data-layer errors, lock failures) is caught, logged, and rethrown as BusinessException(ResponseEnum.NOTIFICATION_DELETE_FAILED). BusinessException is rethrown unchanged, so this code always signals an unexpected server-side delete failure.","triggerScenarios":"Database delete fails (connection issues, constraint violations, table lock); distributed lock around deleteNotification errors; serialization/persistence layer exceptions inside deleteUserNotification.","commonSituations":"DB outage or pool exhaustion; deadlock on the notification table during bulk operations; Redis lock service unavailable causing lock acquisition failures inside the annotated method.","solutions":["Inspect server logs for 'Failed to delete notification' with receiverUid and notificationId to find the root cause.","Verify database connectivity and health; retry once transient issues clear.","Check the distributed-lock (Redis) service status.","If persistent, examine notificationDataService.deleteUserNotification for SQL/constraint errors."],"exampleFix":"// before\n// no retry on transient DB failure\nnotificationService.deleteNotification(uid, id);\n// after\ntry {\n    notificationService.deleteNotification(uid, id);\n} catch (BusinessException e) {\n    // retry with backoff for NOTIFICATION_DELETE_FAILED\n}","handlingStrategy":"try-catch","validationCode":"if (receiverUid != null && notificationId != null) { /* proceed */ }","typeGuard":null,"tryCatchPattern":"try { deleteNotification(uid, id); } catch (BusinessException e) { if (e.getCode() == ResponseEnum.NOTIFICATION_DELETE_FAILED.getCode()) { /* retry with backoff; alert if persistent */ } }","preventionTips":["Implement bounded retry with backoff for delete calls.","Monitor database and distributed-lock service health.","Check server logs for 'Failed to delete notification' when errors recur."],"tags":["notification","database"],"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"}