Uh oh!
There was an error while loading. Please reload this page.
Conversation
| } else { | ||
| try { | ||
| final GlobalLock createSnapshotPolicyLock = GlobalLock.getInternLock("createSnapshotPolicy"); |
There was a problem hiding this comment.
Would be more effective to append the volume id in the lock name to avoid locking the call for all snapshot policy.
There was a problem hiding this comment.
@marcaurele : Implemented the changes as per your suggestion.
I'm not convinced that such a fix is needed. In what scenario do you see such a problem? |
niteshsarda
commented
Dec 25, 2017
@marcaurele : One of our customer have reported this scenario, where they have multiple management servers and when parallel request comes for snapshot policy creation for same volume, then multiple entries are created in DB for same volume. Also, I apologize for confusing title of the PR, I have updated the same, to make it more clear and relevant to the fix. |
rafaelweingartner
commented
Dec 25, 2017
I have experienced the same problem some time ago. I did not manage to reproduce it though. One of the volumes had two "daily snapshots" in the database. |
yadvr
commented
Dec 26, 2017
@blueorangutan package |
blueorangutan
commented
Dec 26, 2017
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
blueorangutan
commented
Dec 26, 2017
Packaging result: ✖centos6 ✔centos7 ✔debian. JID-1488 |
yadvr
commented
Dec 26, 2017
@blueorangutan package |
blueorangutan
commented
Dec 26, 2017
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
| } else { | ||
| try { | ||
| policy = _snapshotPolicyDao.acquireInLockTable(volumeId); |
There was a problem hiding this comment.
You can request a lock for the snapshot policy table for existing entries and by giving a snapshot policy ID only, not the ID of a volume: policy = _snapshotPolicyDao.acquireInLockTable(policyId);
In your case you don't have a policy id yet when creating a new one. You'll have to use the global lock.
There was a problem hiding this comment.
@marcaurele : Changed the code as per your suggestion. Now added a code for using global lock along with volume id added in the lock name.
Can you please review the new code ?
blueorangutan
commented
Dec 26, 2017
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1504 |
| try { | ||
| final GlobalLock createSnapshotPolicyLock = GlobalLock.getInternLock("createSnapshotPolicy_" + volumeId); | ||
| createSnapshotPolicyLock.lock(5); |
There was a problem hiding this comment.
The return value is not checked (boolean) which should handle the case when the lock could not be acquired.
There was a problem hiding this comment.
@marcaurele : Do we just need to add the debug logger if lock is not acquired ?
Please confirm.
There was a problem hiding this comment.
If the lock is not acquired you have to stop processing the request and return a failure to the user. Look at other part of the code using that lock mechanism.
There was a problem hiding this comment.
@marcaurele : Incorporated the changes suggested by you for handling the condition of lock not acquired. In case if lock is not acquired, null value will be returned.
In CreateSnapshotPolicyCmd class, inside execute method from where this method is called, we have already handled the null condition, and in case of null value exception will be thrown.
Please review the latest code.
marcaurele
left a comment
There was a problem hiding this comment.
Last little change on the log level
| CallContext.current().putContextParameter(SnapshotPolicy.class, policy.getUuid()); | ||
| return policy; | ||
| } else { | ||
| s_logger.debug("Unable to acquire lock for creating snapshot policy of volume : " + volume.getName()); |
There was a problem hiding this comment.
This log should be move to the warn level
There was a problem hiding this comment.
@marcaurele : Changed the log level to warn.
Please check latest code.
niteshsarda
commented
Dec 28, 2017
@rhtyd : Can you please re-run the test cases again ? |
yadvr
commented
Dec 28, 2017
sure @niteshsarda |
blueorangutan
commented
Dec 28, 2017
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
niteshsarda
commented
Dec 28, 2017
@rhtyd : Thank you. |
blueorangutan
commented
Dec 28, 2017
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1510 |
yadvr
commented
Dec 28, 2017
Re-kick as commit was pushed after last pkg build run |
blueorangutan
commented
Dec 28, 2017
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
…DB for same volume.
blueorangutan
commented
Dec 28, 2017
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1516 |
niteshsarda
commented
Jan 1, 2018
@rhtyd : Can you please re-run the test cases again as results for previous execution is not posted yet? |
yadvr
commented
Jan 1, 2018
Tests haven't been kicked yet. |
blueorangutan
commented
Jan 1, 2018
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
blueorangutan
commented
Jan 1, 2018
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1532 |
yadvr
commented
Jan 1, 2018
@blueorangutan test |
blueorangutan
commented
Jan 1, 2018
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
blueorangutan
commented
Jan 1, 2018
Trillian test result (tid-1961)
|
yadvr
commented
Jan 2, 2018
Lgtm. Merging this based on 2 lgtms and test results. |
Refatoração nos _parsers_ do Usage Closesapache#1056, apache#2373, and apache#2387 See merge request scclouds/scclouds!966
ISSUE :
createSnapshotPolicy API create multiple entries in DB for same parameters, if multiple threads are executed in parallel.
STEPS TO REPRODUCE :