-
Notifications
You must be signed in to change notification settings - Fork 86
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
fix: session file driver problem when concurrent #550
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Session
participant File
User->>Session: Write(id, data)
Session->>File: Write(id, data)
File->>File: Lock mutex
File-->>File: Perform write operation
File->>File: Unlock mutex
File-->>Session: Write result
User->>Session: Read(id)
Session->>File: Read(id)
File->>File: Lock mutex
File-->>File: Perform read operation
File->>File: Unlock mutex
File-->>Session: Read result
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## v1.14.x #550 +/- ##
==========================================
Coverage ? 70.35%
==========================================
Files ? 176
Lines ? 10978
Branches ? 0
==========================================
Hits ? 7724
Misses ? 2686
Partials ? 568 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- session/driver/file.go (5 hunks)
- session/driver/file_test.go (2 hunks)
Additional comments not posted (6)
session/driver/file.go (5)
7-7
: Good addition ofsync.Mutex
for thread safety.The import of the
sync
package and the addition of themu
field in theFile
struct are appropriate for ensuring thread-safe operations.Also applies to: 16-16
31-33
: Thread safety inDestroy
method.The use of
mu.Lock()
anddefer mu.Unlock()
ensures that theDestroy
method is thread-safe.
38-40
: Thread safety inGc
method.The use of
mu.Lock()
anddefer mu.Unlock()
ensures that theGc
method is thread-safe.
65-67
: Thread safety inRead
method.The use of
mu.Lock()
anddefer mu.Unlock()
ensures that theRead
method is thread-safe.
87-89
: Thread safety inWrite
method.The use of
mu.Lock()
anddefer mu.Unlock()
ensures that theWrite
method is thread-safe.session/driver/file_test.go (1)
112-130
: Well-structured concurrent test.The
TestReadWriteWithConcurrent
function effectively validates the thread safety of read and write operations usingsync.WaitGroup
.
📑 Description
Closes https://github.com/goravel/goravel/issues/?
Summary by CodeRabbit
Bug Fixes
Tests
✅ Checks