diff options
| author | chrislu <chris.lu@gmail.com> | 2025-10-30 20:41:30 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2025-10-30 20:41:30 -0700 |
| commit | 60f9dea60a8b6d892d35ee94a77bfbc19c0fe402 (patch) | |
| tree | 5cb31f01117288bf3fbc4650b0cc42540a09a97f /postgres-examples/test_client.py | |
| parent | cb952ff10703629e5bd40d701eb1e6486a4630f6 (diff) | |
| download | seaweedfs-60f9dea60a8b6d892d35ee94a77bfbc19c0fe402.tar.xz seaweedfs-60f9dea60a8b6d892d35ee94a77bfbc19c0fe402.zip | |
Optimize vidMap locking for better concurrency
Improved locking strategy based on the understanding that:
- vidMapLock protects the vidMap pointer from concurrent swaps
- vidMap has internal locks that protect its data structures
Changes:
1. Read operations: Grab pointer with RLock, release immediately, then operate
- Reduces lock hold time
- Allows resetVidMap to proceed sooner
- Methods: GetLocations, GetLocationsClone, GetVidLocations,
LookupVolumeServerUrl, GetDataCenter
2. Write operations: Changed from Lock() to RLock()
- RLock prevents pointer swap during operation
- Allows concurrent readers and other writers (serialized by vidMap's lock)
- Methods: addLocation, deleteLocation, addEcLocation, deleteEcLocation
Benefits:
- Significantly reduced lock contention
- Better concurrent performance under load
- Still prevents all race conditions
Verified with: go test -race ./weed/wdclient/... (passes)
Diffstat (limited to 'postgres-examples/test_client.py')
0 files changed, 0 insertions, 0 deletions
