mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-15 18:12:35 +01:00
avoid mysql lock-promotion situation.
This commit is contained in:
parent
0c1b6b44a8
commit
de252adadf
@ -899,7 +899,8 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateState(Status oldStatus, Event event, Status newStatus, Host vo, Object data) {
|
public boolean updateState(Status oldStatus, Event event, Status newStatus, Host vo, Object data) {
|
||||||
HostVO host = findById(vo.getId());
|
// lock target row from beginning to avoid lock-promotion caused deadlock
|
||||||
|
HostVO host = lockRow(vo.getId(), true);
|
||||||
if (host == null) {
|
if (host == null) {
|
||||||
if (event == Event.Remove && newStatus == Status.Removed) {
|
if (event == Event.Remove && newStatus == Status.Removed) {
|
||||||
host = findByIdIncludingRemoved(vo.getId());
|
host = findByIdIncludingRemoved(vo.getId());
|
||||||
|
|||||||
@ -437,6 +437,9 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lock the target row at beginning to avoid lock-promotion caused deadlock
|
||||||
|
lockRow(vm.getId(), true);
|
||||||
|
|
||||||
SearchCriteria<VMInstanceVO> sc = StateChangeSearch.create();
|
SearchCriteria<VMInstanceVO> sc = StateChangeSearch.create();
|
||||||
sc.setParameters("id", vmi.getId());
|
sc.setParameters("id", vmi.getId());
|
||||||
sc.setParameters("states", oldState);
|
sc.setParameters("states", oldState);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user