mirror of https://github.com/apache/cloudstack.git
Use row lock instead of global lock when creating a new domain
This commit is contained in:
parent
0cdb67fdc7
commit
9c47f6bd94
|
|
@ -99,36 +99,31 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
|
|||
return null;
|
||||
}
|
||||
|
||||
GlobalLock lock = GlobalLock.getInternLock("lock.domain." + parent);
|
||||
if(!lock.lock(3600)) {
|
||||
// wait up to 1 hour, if it comes up to here, something is wrong
|
||||
s_logger.error("Unable to lock parent domain: " + parent);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
|
||||
parentDomain = this.lockRow(parent, true);
|
||||
if(parentDomain == null) {
|
||||
s_logger.error("Unable to lock parent domain: " + parent);
|
||||
return null;
|
||||
}
|
||||
|
||||
domain.setPath(allocPath(parentDomain, domain.getName()));
|
||||
domain.setLevel(parentDomain.getLevel() + 1);
|
||||
|
||||
parentDomain.setNextChildSeq(parentDomain.getNextChildSeq() + 1); // FIXME: remove sequence number?
|
||||
parentDomain.setChildCount(parentDomain.getChildCount() + 1);
|
||||
persist(domain);
|
||||
update(parentDomain.getId(), parentDomain);
|
||||
|
||||
txn.commit();
|
||||
return domain;
|
||||
} catch(Exception e) {
|
||||
s_logger.error("Unable to create domain due to " + e.getMessage(), e);
|
||||
txn.rollback();
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
|
||||
domain.setPath(allocPath(parentDomain, domain.getName()));
|
||||
domain.setLevel(parentDomain.getLevel() + 1);
|
||||
|
||||
parentDomain.setNextChildSeq(parentDomain.getNextChildSeq() + 1); // FIXME: remove sequence number?
|
||||
parentDomain.setChildCount(parentDomain.getChildCount() + 1);
|
||||
persist(domain);
|
||||
update(parentDomain.getId(), parentDomain);
|
||||
|
||||
txn.commit();
|
||||
return domain;
|
||||
} catch(Exception e) {
|
||||
s_logger.error("Unable to create domain due to " + e.getMessage(), e);
|
||||
txn.rollback();
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue