Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

set log level of optimism to debug

  • Loading branch information...
commit 8e8d63348764eb333336d512423d03fcb4b86670 1 parent bd14674
Kyle Maxwell authored
View
6 config/test.scala
@@ -23,8 +23,8 @@ class TestQueryEvaluator(label: String) extends QueryEvaluator {
// query.debug = DebugLog
database.memoize = true
database.pool = new ApachePoolingDatabase {
- sizeMin = 10
- sizeMax = 10
+ sizeMin = 8
+ sizeMax = 8
maxWait = 1.second
minEvictableIdle = 60.seconds
testIdle = 1.second
@@ -115,7 +115,7 @@ new FlockDB {
maxMemorySize = 36000000L
}
- threads = 4
+ threads = 2
errorLimit = 25
errorRetryDelay = 900.seconds
errorStrobeInterval = 30.seconds
View
2  project/build.properties
@@ -3,6 +3,6 @@
project.organization=com.twitter
project.name=flockdb
sbt.version=0.7.4
-project.version=1.5.1-mc-SNAPSHOT
+project.version=1.5.1-optimism-SNAPSHOT
build.scala.versions=2.7.7
project.initialize=false
View
33 src/main/scala/com/twitter/flockdb/shards/Optimism.scala
@@ -2,6 +2,7 @@ package com.twitter.flockdb.shards
import com.twitter.gizzard.shards.ShardException
import com.twitter.util.Time
+import net.lag.logging.Logger
class OptimisticLockException(message: String) extends ShardException(message)
@@ -54,21 +55,33 @@ class OptimisticLockException(message: String) extends ShardException(message)
trait Optimism extends Shard {
protected case class MetadataWithEx(metadata: Metadata, ex: Option[Throwable])
- def optimistically(sourceId: Long)(f: State => Unit) = {
+ private val log = Logger.get(getClass.getName)
- var before = getWinner(sourceId)
+ def optimistically(sourceId: Long)(f: State => Unit) = {
+ try {
+ log.debug("starting optimistic lock of " + shardInfo.id + " for " + sourceId)
+ var before = getWinner(sourceId)
- f(before.metadata.state)
+ f(before.metadata.state)
- // We didn't do this immediately, because we still want to propagate writes with best effort.
- // We should reenqueue if the optimistic lock only covers a subset of the intended targets.
- before.ex.foreach(throw _)
+ // We didn't do this immediately, because we still want to propagate writes with best effort.
+ // We should reenqueue if the optimistic lock only covers a subset of the intended targets.
+ before.ex.foreach(throw _)
- var after = getWinner(sourceId)
- after.ex.foreach(throw _)
+ var after = getWinner(sourceId)
+ after.ex.foreach(throw _)
- if(before.metadata.state != after.metadata.state) {
- throw new OptimisticLockException("Lost optimistic lock for " + sourceId + ": was " + before.metadata.state +", now " + after.metadata.state)
+ if(before.metadata.state != after.metadata.state) {
+ val message = shardInfo.id + " lost optimistic lock for " + sourceId + ": was " + before.metadata.state +", now " + after.metadata.state
+ log.debug(message)
+ throw new OptimisticLockException(message)
+ }
+ log.debug("successful optimistic lock of " + shardInfo.id + " for " + sourceId)
+ } catch {
+ case e: Throwable => {
+ log.debug("exception in optimistic lock of " + shardInfo.id + " for " + sourceId + ": " + e.getMessage)
+ throw(e)
+ }
}
}
View
2  src/test/scala/com/twitter/flockdb/integration/OptimisticLockRegressionSpec.scala
@@ -74,7 +74,7 @@ class OptimisticLockRegressionSpec extends IntegrationSpecification() {
var found = false
while (errors.size > 0) {
val job = errors.get.get.job
- if (job.toString.indexOf("Lost optimistic lock") > 0) {
+ if (job.toString.indexOf("lost optimistic lock") > 0) {
found = true
}
job()
View
2  src/test/scala/com/twitter/flockdb/unit/JobSpec.scala
@@ -43,7 +43,7 @@ class IdentityShard[ConcreteShard <: Shard](shard: ConcreteShard)
extends ReadWriteShard[ConcreteShard] {
val children = Seq(shard)
val weight = 1
- def shardInfo = throw new UnsupportedOperationException()
+ def shardInfo = new ShardInfo("a", "b", "c")
def readAllOperation[A](method: (ConcreteShard => A)) = FanoutResults(method, shard)
def readOperation[A](method: (ConcreteShard => A)) = method(shard)
Please sign in to comment.
Something went wrong with that request. Please try again.