Pure dry goods.
Direct cause: problems caused by concurrent read/write of map. The source of your problem must be among the following reasons.
catalogue
Reason 1: abnormal loading and unlocking
Reason 2: adding unlock code looks normal
Reason 3: incomplete locking
Reason 4: the same lock is not added to the map
Reason 1: abnormal loading and unlocking
The code is not written rigorously, the lock is not unlocked, and a single closed loop is not formed
solution: if a closed loop is formed, there must be a solution
Reason 2: adding unlock code looks normal
In fact, the internal code of the lock is lonely. The map operation is not within the scope of the lock. The (read and write together) or the same map (same address) is used with the external code. The lock does not play a practical role
Solution: transfer the map data without using the old map, generate a new map between locking and unlocking,
transfer the data to the new map (or other data structures), and then return to the new map
Or
Just adjust the code position
Reason 3: incomplete locking
Only the goroutine that writes the map is unlocked, but the goroutine that reads the map is not or only goroutine reading map is unlocked, but goroutine writing is not or unlocked
Reason 4: the same lock is not added to the map
For example: for a map, there are two goroutines for reading the map and two goroutines for writing the map. The four are numbered 1,2,3,4. The first three use mu1 and the last one uses mu2, which will cause the error.
Warm tips:
the same lock can act on multiple maps, but the same map cannot have two locks.
Read More:
- [Go] Solve the fatal error: concurrent map writes map is not concurrently safe
- Golang Error: fatal error: concurrent map read and map writ
- [Solved] Golang Error: fatal error: concurrent map writes
- Hash_map is deprecated and will be REMOVED. Please use unordered_map.
- How to Solve Error: IncompleteElementException: Could not find result map…
- How to Solve Cordova integrates Gaode Map key error
- How to Solve Error: Missing type map configuration or unsupported mapping
- [Solved] cocopod Error: failed: undefined method `map‘ for nil:NilClass
- Max virtual memory areas vm.max_map_count [65530] is too low, increase to at least
- [Solved] Searching for inspections failed: undefined method `map‘ for nil:NilClass“
- [Solved] IP Core Map Compile Error: Buffers of the same direction cannot beplaced in series.
- Failed to remove multipath map 320b508ca45022b80 [How to Solve]
- How to Solve Docker Run Error: standard_init_linux.go:219: exec user process caused: exec format error
- [Solved] Eclipse Connect Hadoop error: /An internal error occurred during: “Map/Reduce location status updater“
- Vue Import Baidu map error: BMap is not defined, eslint BMap reports an error
- Implement base64_decode in GO language to solve the problem of illegal characters
- [Solved] Error running ‘go build myfir_go_project‘: Cannot run program
- [Solved] Golang Error: main.go:5:2: package go_code/chapter10/factory/model is not in GOROOT
- [Solved] Exception while doing past iteration backup