-
Notifications
You must be signed in to change notification settings - Fork 66
Guard 2.0.1 database transactions with a mutex #589
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
Conversation
lib/ocpp/v201/database_handler.cpp
Outdated
| throw std::runtime_error("Table does not exist."); | ||
| } | ||
|
|
||
| std::scoped_lock lock(this->database_transaction_mutex); |
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.
I would suggest to do this more generically by putting this in the database connection somehow. Apparently you can't have more than 1 transaction per connection so that seems to be the perfect place. Lock on begin transaction and unlock on the commit or rollback.
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.
Yes that sounds like a good idea!
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.
For the record, we discussed this morning I will pick this one up ;)
577f803 to
e72168f
Compare
Otherwise it might happen that we try to insert metervalues into the database while another transaction event is happening. In certain circumstances (for example with multiple EVSEs present) this can lead to a "Could not begin transaction" exception Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Marc Emmers <m.emmers@alfen.com>
Signed-off-by: Marc Emmers <m.emmers@alfen.com>
e72168f to
024aba6
Compare
Co-authored-by: Piet Gömpel <37657534+Pietfried@users.noreply.github.com> Signed-off-by: Marc Emmers <35759328+marcemmers@users.noreply.github.com>
* Guard 2.0.1 database transactions with a mutex Otherwise it might happen that we try to insert metervalues into the database while another transaction event is happening. In certain circumstances (for example with multiple EVSEs present) this can lead to a "Could not begin transaction" exception Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de> * Add transaction class handling the locking of the interface Signed-off-by: Marc Emmers <m.emmers@alfen.com> * Fix small issues Signed-off-by: Marc Emmers <m.emmers@alfen.com> * Update include/ocpp/common/database/database_connection.hpp Co-authored-by: Piet Gömpel <37657534+Pietfried@users.noreply.github.com> Signed-off-by: Marc Emmers <35759328+marcemmers@users.noreply.github.com> --------- Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de> Signed-off-by: Marc Emmers <m.emmers@alfen.com> Signed-off-by: Marc Emmers <35759328+marcemmers@users.noreply.github.com> Co-authored-by: Marc Emmers <m.emmers@alfen.com> Co-authored-by: Marc Emmers <35759328+marcemmers@users.noreply.github.com> Co-authored-by: Piet Gömpel <37657534+Pietfried@users.noreply.github.com>
* Guard 2.0.1 database transactions with a mutex Otherwise it might happen that we try to insert metervalues into the database while another transaction event is happening. In certain circumstances (for example with multiple EVSEs present) this can lead to a "Could not begin transaction" exception Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de> * Add transaction class handling the locking of the interface Signed-off-by: Marc Emmers <m.emmers@alfen.com> * Fix small issues Signed-off-by: Marc Emmers <m.emmers@alfen.com> * Update include/ocpp/common/database/database_connection.hpp Co-authored-by: Piet Gömpel <37657534+Pietfried@users.noreply.github.com> Signed-off-by: Marc Emmers <35759328+marcemmers@users.noreply.github.com> --------- Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de> Signed-off-by: Marc Emmers <m.emmers@alfen.com> Signed-off-by: Marc Emmers <35759328+marcemmers@users.noreply.github.com> Co-authored-by: Marc Emmers <m.emmers@alfen.com> Co-authored-by: Marc Emmers <35759328+marcemmers@users.noreply.github.com> Co-authored-by: Piet Gömpel <37657534+Pietfried@users.noreply.github.com> Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com>
Otherwise it might happen that we try to insert metervalues into the database while another transaction event is happening. In certain circumstances (for example with multiple EVSEs present) this can lead to a "Could not begin transaction" exception
Describe your changes
Issue ticket number and link
Checklist before requesting a review