{"record":{"id":"97179563816ccafa","repo":"cilium/cilium","slug":"update-map-s-w","errorCode":null,"errorMessage":"update map %s: %w","messagePattern":"update map (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bpf/map_linux.go","lineNumber":1302,"sourceCode":"\t\t\tm.updatePressureMetric()\n\t\t} else if err == nil {\n\t\t\tm.cache[key.String()] = nil\n\t\t\tm.updatePressureMetric()\n\t\t}\n\t}()\n\n\tif err = m.open(); err != nil {\n\t\treturn err\n\t}\n\n\terr = m.m.Update(key, value, ebpf.UpdateAny)\n\n\tif metrics.BPFMapOps.IsEnabled() {\n\t\tmetrics.BPFMapOps.WithLabelValues(m.commonName(), metricOpUpdate, metrics.Error2Outcome(err)).Inc()\n\t}\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"update map %s: %w\", m.Name(), err)\n\t}\n\n\treturn nil\n}\n\n// deleteMapEvent is run at every delete map event.\n// If cache is enabled, it will update the cache to reflect the delete.\n// As well, if event buffer is enabled, it adds a new event to the buffer.\nfunc (m *Map) deleteMapEvent(key MapKey, err error) {\n\tm.addToEventsLocked(MapDelete, cacheEntry{\n\t\tKey:           key,\n\t\tDesiredAction: Delete,\n\t\tLastError:     err,\n\t})\n\tm.deleteCacheEntry(key, err)\n}\n\nfunc (m *Map) deleteAllMapEvent() {","sourceCodeStart":1284,"sourceCodeEnd":1320,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/bpf/map_linux.go#L1284-L1320","documentation":"Update() writes a key/value into the underlying ebpf map and wraps any non-nil error from the kernel update call as 'update map %s'. The wrap includes the metric emission via Error2Outcome, meaning this covers any ebpf update failure: map full, invalid key/value size, map closed, or bad flags.","triggerScenarios":"Update() on a full hash/LRU map with ebpf.UpdateNoExist or no LRU eviction capacity; key or value byte length not matching the spec's KeySize/ValueSize; map closed or unpinned concurrently; invalid update flags (e.g. UpdateNoExist on an existing key).","commonSituations":"MaxEntries too small for workload traffic; struct layout changed (cgo/type mismatch) so marshalled key size no longer matches; LRU map replaced with plain hash causing 'map full'; calling Update after Close during shutdown.","solutions":["Inspect the wrapped cause: increase MaxEntries or switch to LRUHash if the error is 'map full' (ebpf.KeyExists/ENOSPC)","Validate key/value sizes against the MapSpec's KeySize/ValueSize before calling Update","Verify update flags match intent (UpdateAny vs UpdateNoExist/UpdateExist)","Ensure the map is open (not concurrently closed) when Update is invoked"],"exampleFix":"// before\nspec := &ebpf.MapSpec{Type: ebpf.Hash, MaxEntries: 8}\nm.Update(key, val) // update map flows: map full\n// after\nspec := &ebpf.MapSpec{Type: ebpf.LRUHash, MaxEntries: 65536}\nm.Update(key, val)","handlingStrategy":"try-catch","validationCode":"if len(kb) != m.KeySize() || len(vb) != m.ValueSize() {\n    return fmt.Errorf(\"key=%d value=%d bytes, map expects %d/%d\", len(kb), len(vb), m.KeySize(), m.ValueSize())\n}\nif m.IsLRU() && m.Len() >= int(m.MaxEntries()) { /* capacity warning */ }","typeGuard":null,"tryCatchPattern":"if err := m.Update(key, val); err != nil {\n    if errors.Is(err, unix.ENOSPC) || strings.Contains(err.Error(), \"map full\") {\n        return retryWithLRUOrBiggerMap(key, val) // grow MaxEntries / switch to LRUHash\n    }\n    if errors.Is(err, ebpf.ErrKeyExist) { // wrong flag for intent\n        return m.Update(key, val, ebpf.UpdateAny)\n    }\n    return fmt.Errorf(\"update map: %w\", err)\n}","preventionTips":["Size MaxEntries for peak traffic or use LRUHash for eviction","Keep key/value Go types byte-stable; re-pin maps when layouts change","Use the correct update flags (UpdateAny vs UpdateNoExist)","Watch BPFMapOps metrics for rising update-failure outcomes"],"tags":["ebpf","map-update","capacity","kernel"],"backgroundTag":"bpf-map-update-failed","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}