-
Notifications
You must be signed in to change notification settings - Fork 81
added len method #708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
added len method #708
Conversation
084e9aa to
3a61ef3
Compare
676496b to
4433ac8
Compare
| c.readIndex = 0 // Reset read position to allow Read() after Len() | ||
| } | ||
| return len(c.cachedResults) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Concurrent Access Causes Data Races
The Len() method modifies shared state (cached, cachedResults, cachedErrors, readIndex) without synchronization, creating race conditions when multiple goroutines call Len() or Read() concurrently on the same reader. The same reader instance could be accessed from multiple goroutines, causing data races and unpredictable behavior.
| c.readIndex = 0 // Reset read position to allow Read() after Len() | ||
| } | ||
| return len(c.cachedResults) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Concurrent Access Corrupts Shared Reader State
The Len() method modifies shared state (cached, cachedResults, cachedErrors, readIndex) without synchronization, creating race conditions when multiple goroutines call Len() or Read() concurrently on the same reader. The same reader instance could be accessed from multiple goroutines, causing data races and unpredictable behavior.
| c.readIndex = 0 // Reset read position to allow Read() after Len() | ||
| } | ||
| return len(c.cachedResults) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Race Conditions from Unsynchronized Shared State
The Len() method modifies shared state (cached, cachedResults, cachedErrors, readIndex) without synchronization, creating race conditions when multiple goroutines call Len() or Read() concurrently on the same reader. The same reader instance could be accessed from multiple goroutines, causing data races and unpredictable behavior.
| c.readIndex = 0 // Reset read position to allow Read() after Len() | ||
| } | ||
| return len(c.cachedResults) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unsynchronized shared state leads to data races.
The Len() method modifies shared state (cached, cachedResults, cachedErrors, readIndex) without synchronization, creating race conditions when multiple goroutines call Len() or Read() concurrently on the same reader. The same reader instance could be accessed from multiple goroutines, causing data races and unpredictable behavior.
| c.readIndex = 0 // Reset read position to allow Read() after Len() | ||
| } | ||
| return len(c.cachedResults) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Concurrency Bug: Unsynchronized Shared State
The Len() method modifies shared state (cached, cachedResults, cachedErrors, readIndex) without synchronization, creating race conditions when multiple goroutines call Len() or Read() concurrently on the same reader. The same reader instance could be accessed from multiple goroutines, causing data races and unpredictable behavior.
Added len() method for collections CRUD operations
Closes: #686
Note
Adds Len() to collection CRUD response readers with caching, introduces shared ReadAll utilities, refactors readers to fix Old/New handling, and updates tests/benchmarks accordingly.
Len()toCollectionDocument*ResponseReaderinterfaces (create,read,update,replace,delete).Len()while preservingRead()iteration.shared.ReadAllReaderandshared.ReadAllIntoReaderutilities and wire them into readers.Old/Newhandling: per-item instance creation via cachedreflect.Typeand back-propagation to provided option objects.v2/arangodb/shared/read_all.gowith genericReadAllhelpers for readers (with and without into-parameter).ReadAll(...), validateLen()behavior implicitly via caching, and assertmeta.Oldpopulation for deletes.ReadDocumentsdirectly and minor setup cleanups.len()for Read methods undermaster.Written by Cursor Bugbot for commit 4433ac8. This will update automatically on new commits. Configure here.