-
Notifications
You must be signed in to change notification settings - Fork 268
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
Add synchronization when locking database connection #1200
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,7 +99,7 @@ object SqliteUtils { | |
* | ||
* The lock will be kept until the database is closed, or if the locking mode is explicitly reset. | ||
*/ | ||
def obtainExclusiveLock(sqlite: Connection) { | ||
def obtainExclusiveLock(sqlite: Connection) = synchronized { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only fixes the issue if two calls to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This scenario is taken care of by the front application and should not happen. There's a logic that prevents background jobs to run concurrently with the front. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok in that case the |
||
val statement = sqlite.createStatement() | ||
statement.execute("PRAGMA locking_mode = EXCLUSIVE") | ||
// we have to make a write to actually obtain the lock | ||
|
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.
It seems like we should try to avoid extending this
Logging
trait and instead implicitly pass a logger to the functions that need one. Can you try doing that?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.
Using
grizzled.slf4j.Logging
is indeed discouraged, but for code completely unrelated to actors I think it makes sense to keep using it. What we don't want is lose the context when we call code in static methods from within an actor.