public void DetectDeadlockPolicy( string home, DeadlockPolicy deadlock) { Configuration.ClearDir(home); DatabaseEnvironmentConfig envConfig = new DatabaseEnvironmentConfig(); envConfig.Create = true; envConfig.UseLocking = true; envConfig.UseLogging = true; envConfig.UseMPool = true; envConfig.UseTxns = true; DatabaseEnvironment env = DatabaseEnvironment.Open( home, envConfig); env.DeadlockResolution = deadlock; Assert.AreEqual(deadlock, env.DeadlockResolution); env.DetectDeadlocks(deadlock); env.Close(); }
public static void ConfirmDeadlockPolicy(XmlElement xmlElem, string name, DeadlockPolicy deadlockPolicy, bool compulsory) { XmlNode xmlNode = XMLReader.GetNode(xmlElem, name); if (xmlNode == null && compulsory == true) throw new ConfigNotFoundException(name); else if (xmlNode != null) { string policy = xmlNode.InnerText; if (policy == "DEFAULT") Assert.AreEqual(DeadlockPolicy.DEFAULT, deadlockPolicy); else if (policy == "EXPIRE") Assert.AreEqual(DeadlockPolicy.EXPIRE, deadlockPolicy); else if (policy == "MAX_LOCKS") Assert.AreEqual(DeadlockPolicy.MAX_LOCKS, deadlockPolicy); else if (policy == "MAX_WRITE") Assert.AreEqual(DeadlockPolicy.MAX_WRITE, deadlockPolicy); else if (policy == "MIN_LOCKS") Assert.AreEqual(DeadlockPolicy.MIN_LOCKS, deadlockPolicy); else if (policy == "MIN_WRITE") Assert.AreEqual(DeadlockPolicy.MIN_WRITE, deadlockPolicy); else if (policy == "OLDEST") Assert.AreEqual(DeadlockPolicy.OLDEST, deadlockPolicy); else if (policy == "RANDOM") Assert.AreEqual(DeadlockPolicy.RANDOM, deadlockPolicy); else if (policy == "YOUNGEST") Assert.AreEqual(DeadlockPolicy.YOUNGEST, deadlockPolicy); else throw new InvalidConfigException(name); } }
/// <summary> /// Run one iteration of the deadlock detector. The deadlock detector /// traverses the lock table and marks one of the participating lock /// requesters for rejection in each deadlock it finds. /// </summary> /// <param name="atype">Specify which lock request(s) to reject</param> /// <returns>The number of lock requests that were rejected.</returns> public uint DetectDeadlocks(DeadlockPolicy atype) { uint rejectCount = 0; if (atype == null) atype = DeadlockPolicy.DEFAULT; dbenv.lock_detect(0, atype.policy, ref rejectCount); return rejectCount; }
public static bool ConfigDeadlockPolicy(XmlElement xmlElem, string name, ref DeadlockPolicy deadlockPolicy, bool compulsory) { XmlNode xmlNode = XMLReader.GetNode(xmlElem, name); if (xmlNode == null && compulsory == false) return false; else if (xmlNode == null && compulsory == true) throw new ConfigNotFoundException(name); string policy = xmlNode.InnerText; if (policy == "DEFAULT") deadlockPolicy = DeadlockPolicy.DEFAULT; else if (policy == "EXPIRE") deadlockPolicy = DeadlockPolicy.EXPIRE; else if (policy == "MAX_LOCKS") deadlockPolicy = DeadlockPolicy.MAX_LOCKS; else if (policy == "MAX_WRITE") deadlockPolicy = DeadlockPolicy.MAX_WRITE; else if (policy == "MIN_LOCKS") deadlockPolicy = DeadlockPolicy.MIN_LOCKS; else if (policy == "MIN_WRITE") deadlockPolicy = DeadlockPolicy.MIN_WRITE; else if (policy == "OLDEST") deadlockPolicy = DeadlockPolicy.OLDEST; else if (policy == "RANDOM") deadlockPolicy = DeadlockPolicy.RANDOM; else if (policy == "YOUNGEST") deadlockPolicy = DeadlockPolicy.YOUNGEST; else throw new InvalidConfigException(name); return true; }