Repository navigation
Conversation
There was a problem hiding this comment.
increasing count even if done is true. in last loop, will throw error below, also if success.
after loop, having
- done = true
- count === $maxTry
There was a problem hiding this comment.
- show exact query and values, to allow cleanup. If happening, there is some inconsistent metadata.
- Use $maxTry instead of "10" in exception text.
There was a problem hiding this comment.
Hack. Please leave comment for easy understanding such hacks
There was a problem hiding this comment.
I just don't understand, please explain why wrapping the logic in transaction.
- Only one changing (successful) query, why keeping it together with the failing ones?
- This could still lead to a deadlock in DB cluster, right?
- has this impact on requirements for wsrep_autocommit configs?
- What would happen without transaction?
There was a problem hiding this comment.
I would expect this function to insert or not. So if the constraint violation is due to $compare values (race condition, other process inserted s.th.) all is fine (don't throw error), return 0 and handle as if existing already.
If violation is due to primary key, then recheck and retry.
|
Are there "integration tests" for testing our "DB Layer" against a real DB? Does it make sense to have our DB Layer in a separat lib with clear testing coverage? |
adf84eb to
c6e3415
Compare
Yes - they live in the |
|
Ahhhh, I just found IDBConnection->setValues() which calls insertIfNotExsits and then update.... hmmmm |
|
Currently, testing this with very occasionally. |
|
Is this because of nested transactions in DBAL? Does the lock actually get removed from the row until the final commit() ? |
|
So added a catch for the deadlock exception and continues the loop of attempts. DeadLockException is in doctrine 2.6+, which has a min php verison of 7.1 😒 How about 10.0.3 requires PHP 7.1?! 🙈 |
|
At least when PHP 5.* is no longer being supported, go straight to 7.1 - I don't see any joy in supporting 7.0 |
|
Caught any other exceptions and throw them onwards. Working on an enhanced test suite for this with all the $compare magic handled. |
21b5b36 to
0c70af8
Compare
|
Rebased to kick Jenkins |
fbe3ee7 to
ec0b313
Compare
|
First breaking commit: 120005b |
|
restarted build |
|
@tomneedham guess who's unhappy: OCI! |
PVince81
left a comment
There was a problem hiding this comment.
👍 from me for @tomneedham's commit.
Would be good to get a second review from @DeepDiver1975 or @butonic as this is slightly dangerous DB stuff
|
Yup - expected that issue with OCI - and agree with the fix |
|
👍 |
Codecov Report
@@ Coverage Diff @@
## master #28698 +/- ##
============================================
+ Coverage 60.21% 60.26% +0.05%
- Complexity 17182 17202 +20
============================================
Files 1030 1030
Lines 57271 57328 +57
============================================
+ Hits 34485 34549 +64
+ Misses 22786 22779 -7
Continue to review full report at Codecov.
|
|
Moving to planned for next release. As soon as 10.0.4 is out I'd like to merge this to have it in the first 10.0.5 beta1 for proper testing. |
|
Yeeeeeehaaaawwwww! Now we just need to retest Galera Multi Master under load! |
|
and it's not the end of the story: there are likely more code paths where we want to switch from |
|
Please backport! |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Implements a proper upsert method.
Wrapped in a transaction:
Tries 10 times (added this in case something else goes crazy and we get stuck) else throws RunTimeException.
Still WIP and open for discussion / thoughts.
One point is that currently I try update, then try insert. This is the opposite when compared to the current implementation - could leave to performance improvements / degradation, depending on common usages of this?
So, checking the usages:

I would say most of these are insert-biased - opinions?
Related Issue
#22563
Motivation and Context
Our current insertOrUpdate method is vulnerable to race conditions.
How Has This Been Tested?
UI / files:scan usage so far. And
db:stress -ffrom owncloud/diagnostics:stress branchScreenshots (if appropriate):
Types of changes
Checklist: