mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
CLOUDSTACK-6236:Negative ref_cnt of template(snapshot/volume)_store_ref results in out-of-range error in Mysql
This commit is contained in:
parent
40192cd8a1
commit
cd8af6a3e2
@ -29,6 +29,8 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
|
||||
@ -44,6 +46,8 @@ import com.cloud.utils.fsm.StateObject;
|
||||
@Entity
|
||||
@Table(name = "snapshot_store_ref")
|
||||
public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
|
||||
private static final Logger s_logger = Logger.getLogger(SnapshotDataStoreVO.class);
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
Long id;
|
||||
@ -272,7 +276,12 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
||||
}
|
||||
|
||||
public void decrRefCnt() {
|
||||
refCnt--;
|
||||
if (refCnt > 0) {
|
||||
refCnt--;
|
||||
}
|
||||
else {
|
||||
s_logger.warn("We should not try to decrement a zero reference count even though our code has guarded");
|
||||
}
|
||||
}
|
||||
|
||||
public Long getVolumeId() {
|
||||
|
||||
@ -29,6 +29,8 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
|
||||
@ -45,6 +47,8 @@ import com.cloud.utils.fsm.StateObject;
|
||||
@Entity
|
||||
@Table(name = "template_store_ref")
|
||||
public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
|
||||
private static final Logger s_logger = Logger.getLogger(TemplateDataStoreVO.class);
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
Long id;
|
||||
@ -367,7 +371,12 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
|
||||
}
|
||||
|
||||
public void decrRefCnt() {
|
||||
refCnt--;
|
||||
if (refCnt > 0) {
|
||||
refCnt--;
|
||||
}
|
||||
else{
|
||||
s_logger.warn("We should not try to decrement a zero reference count even though our code has guarded");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,6 +29,8 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
|
||||
@ -44,6 +46,8 @@ import com.cloud.utils.fsm.StateObject;
|
||||
@Entity
|
||||
@Table(name = "volume_store_ref")
|
||||
public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMachine.State>, DataObjectInStore {
|
||||
private static final Logger s_logger = Logger.getLogger(VolumeDataStoreVO.class);
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
Long id;
|
||||
@ -342,7 +346,12 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
|
||||
}
|
||||
|
||||
public void setRefCnt(Long refCnt) {
|
||||
this.refCnt = refCnt;
|
||||
if (refCnt > 0) {
|
||||
refCnt--;
|
||||
}
|
||||
else {
|
||||
s_logger.warn("We should not try to decrement a zero reference count even though our code has guarded");
|
||||
}
|
||||
}
|
||||
|
||||
public void incrRefCnt() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user