fix: 设置分布式锁超时1分钟解除
This commit is contained in:
@@ -58,7 +58,7 @@ func (s *BackupExportCDRProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:backup_export_cdr:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:backup_export_cdr:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func (s *BackupExportKPIProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:backup_export_kpi:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:backup_export_kpi:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ func (s *BackupExportLogProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:backup_export_log:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:backup_export_log:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func (s *BackupExportUDMProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:backup_export_udm:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:backup_export_udm:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func (s *BackupRemoveFileProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:backup_remove_file:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:backup_remove_file:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package delete_alarm_record
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"be.ems/src/framework/cron"
|
"be.ems/src/framework/cron"
|
||||||
"be.ems/src/framework/database/db"
|
"be.ems/src/framework/database/db"
|
||||||
@@ -31,7 +32,7 @@ func (s *DeleteAlarmRecordProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:delete_alarm_record:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:delete_alarm_record:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"be.ems/src/framework/cron"
|
"be.ems/src/framework/cron"
|
||||||
"be.ems/src/framework/database/db"
|
"be.ems/src/framework/database/db"
|
||||||
@@ -32,7 +33,7 @@ func (s *DeleteCDRRecordProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:delete_cdr_record:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:delete_cdr_record:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"be.ems/src/framework/cron"
|
"be.ems/src/framework/cron"
|
||||||
"be.ems/src/framework/database/db"
|
"be.ems/src/framework/database/db"
|
||||||
@@ -32,7 +33,7 @@ func (s *DeleteKPIRecordProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:delete_kpi_record:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:delete_kpi_record:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func (s *DeleteNeConfigBackupProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:delete_ne_config_backup:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:delete_ne_config_backup:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"be.ems/src/framework/cron"
|
"be.ems/src/framework/cron"
|
||||||
"be.ems/src/framework/database/db"
|
"be.ems/src/framework/database/db"
|
||||||
@@ -32,7 +33,7 @@ func (s *DeleteUENBRecordProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:delete_uenb_record:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:delete_uenb_record:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package monitor_sys_resource
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"be.ems/src/framework/cron"
|
"be.ems/src/framework/cron"
|
||||||
"be.ems/src/framework/database/redis"
|
"be.ems/src/framework/database/redis"
|
||||||
@@ -34,7 +35,7 @@ func (s *MonitorSysResourceProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:monitor_sys_resource:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:monitor_sys_resource:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func (s *NeAlarmStateCheckProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:ne_alarm_state_check:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:ne_alarm_state_check:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ func (s *NeAlarmStateCheckCMDProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:ne_alarm_state_check_cmd:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:ne_alarm_state_check_cmd:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ func (s *NeAlarmStateCheckLicenseProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:ne_alarm_state_check_license:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:ne_alarm_state_check_license:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func (s *NeAlarmStateCheckUDMDBProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:ne_alarm_state_check_udmdb_sync:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:ne_alarm_state_check_udmdb_sync:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package ne_config_backup
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"be.ems/src/framework/cron"
|
"be.ems/src/framework/cron"
|
||||||
"be.ems/src/framework/database/redis"
|
"be.ems/src/framework/database/redis"
|
||||||
@@ -39,7 +40,7 @@ func (s *NeConfigBackupProcessor) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:ne_config_backup:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:ne_config_backup:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package ne_data_udm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"be.ems/src/framework/cron"
|
"be.ems/src/framework/cron"
|
||||||
"be.ems/src/framework/database/redis"
|
"be.ems/src/framework/database/redis"
|
||||||
@@ -38,7 +39,7 @@ func (s *NeDataUDM) Execute(data any) (any, error) {
|
|||||||
|
|
||||||
// 分布式锁,防止多个任务同时执行
|
// 分布式锁,防止多个任务同时执行
|
||||||
lockKey := fmt.Sprintf("processor:ne_data_udm:%s", sysJob.JobID)
|
lockKey := fmt.Sprintf("processor:ne_data_udm:%s", sysJob.JobID)
|
||||||
if ok := redis.SetNX("", lockKey, 0); !ok {
|
if ok := redis.SetNX("", lockKey, time.Minute); !ok {
|
||||||
return nil, cron.ErrTaskRunning
|
return nil, cron.ErrTaskRunning
|
||||||
}
|
}
|
||||||
defer redis.Del("", lockKey)
|
defer redis.Del("", lockKey)
|
||||||
|
|||||||
Reference in New Issue
Block a user