v0.1.35: устранены гонки map (ChangeVisibility/DeleteBatch) и nil-deref под Lock + OverLimit
This commit is contained in:
@@ -42,10 +42,6 @@ func ChangeMessageVisibilityBatchV1(req *http.Request) (int, interfaces.Abstract
|
||||
|
||||
key := tenantQueueKey(t.AccessKey, queueName)
|
||||
|
||||
if _, ok := models.SyncQueues.Queues[key]; !ok {
|
||||
return utils.CreateErrorResponseV1("QueueNotFound", true)
|
||||
}
|
||||
|
||||
if len(requestBody.Entries) == 0 {
|
||||
return utils.CreateErrorResponseV1("EmptyBatchRequest", true)
|
||||
}
|
||||
@@ -66,6 +62,13 @@ func ChangeMessageVisibilityBatchV1(req *http.Request) (int, interfaces.Abstract
|
||||
models.SyncQueues.Lock()
|
||||
defer models.SyncQueues.Unlock()
|
||||
|
||||
// Проверка существования очереди ВНУТРИ Lock: раньше была БЕЗ блокировки
|
||||
// (чтение map) — concurrent map read/write при параллельном DeleteQueue.
|
||||
queue, exists := models.SyncQueues.Queues[key]
|
||||
if !exists {
|
||||
return utils.CreateErrorResponseV1("QueueNotFound", true)
|
||||
}
|
||||
|
||||
successEntries := make([]models.ChangeMessageVisibilityBatchResultEntry, 0)
|
||||
failedEntries := make([]models.BatchResultErrorEntry, 0)
|
||||
|
||||
@@ -81,7 +84,6 @@ func ChangeMessageVisibilityBatchV1(req *http.Request) (int, interfaces.Abstract
|
||||
}
|
||||
|
||||
messageFound := false
|
||||
queue := models.SyncQueues.Queues[key]
|
||||
for i := 0; i < len(queue.Messages); i++ {
|
||||
if queue.Messages[i].ReceiptHandle == entry.ReceiptHandle {
|
||||
if entry.VisibilityTimeout == 0 {
|
||||
@@ -114,7 +116,7 @@ func ChangeMessageVisibilityBatchV1(req *http.Request) (int, interfaces.Abstract
|
||||
|
||||
// Персистим изменения в Redis под Lock
|
||||
if len(successEntries) > 0 {
|
||||
persistence.SaveQueue(key, models.SyncQueues.Queues[key])
|
||||
persistence.SaveQueue(key, queue)
|
||||
}
|
||||
|
||||
respStruct := models.ChangeMessageVisibilityBatchResponse{
|
||||
|
||||
Reference in New Issue
Block a user