Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

janky fix for timeouts !!!

  • Loading branch information...
commit 687575ca5b3b87377d7441a7c69bebd230443426 1 parent de47bf9
Ed Ceaser authored freels committed
View
6 src/main/scala/com/twitter/querulous/AutoDisabler.scala
@@ -12,14 +12,16 @@ trait AutoDisabler {
private var disabledUntil: Time = Time.never
private var consecutiveErrors = 0
- protected def throwIfDisabled() {
+ protected def throwIfDisabled(throwMessage: String): Unit = {
synchronized {
if (Time.now < disabledUntil) {
- throw new SQLException("Server is temporarily disabled")
+ throw new SQLException("Server is temporarily disabled: " + throwMessage)
}
}
}
+ protected def throwIfDisabled(): Unit = { throwIfDisabled("") }
+
protected def noteOperationOutcome(success: Boolean) {
synchronized {
if (success) {
View
2  src/main/scala/com/twitter/querulous/database/ApachePoolingDatabase.scala
@@ -52,7 +52,7 @@ class ApachePoolingDatabase(
config.maxWait = maxWaitForConnectionReservation.inMillis
config.timeBetweenEvictionRunsMillis = checkConnectionHealthWhenIdleFor.inMillis
- config.testWhileIdle = true
+ config.testWhileIdle = false
config.testOnBorrow = checkConnectionHealthOnReservation
config.minEvictableIdleTimeMillis = evictConnectionIfIdleFor.inMillis
View
8 src/main/scala/com/twitter/querulous/database/AutoDisablingDatabase.scala
@@ -7,17 +7,17 @@ import java.sql.{Connection, SQLException, SQLIntegrityConstraintViolationExcept
class AutoDisablingDatabaseFactory(databaseFactory: DatabaseFactory, disableErrorCount: Int, disableDuration: Duration) extends DatabaseFactory {
def apply(dbhosts: List[String], dbname: String, username: String, password: String) = {
- new AutoDisablingDatabase(databaseFactory(dbhosts, dbname, username, password), disableErrorCount, disableDuration)
+ new AutoDisablingDatabase(databaseFactory(dbhosts, dbname, username, password), dbhosts.first, disableErrorCount, disableDuration)
}
def apply(dbhosts: List[String], username: String, password: String) = {
- new AutoDisablingDatabase(databaseFactory(dbhosts, username, password), disableErrorCount, disableDuration)
+ new AutoDisablingDatabase(databaseFactory(dbhosts, username, password), dbhosts.first, disableErrorCount, disableDuration)
}
}
-class AutoDisablingDatabase(database: Database, protected val disableErrorCount: Int, protected val disableDuration: Duration) extends Database with AutoDisabler {
+class AutoDisablingDatabase(database: Database, dbhost: String, protected val disableErrorCount: Int, protected val disableDuration: Duration) extends Database with AutoDisabler {
def open() = {
- throwIfDisabled()
+ throwIfDisabled(dbhost)
try {
val rv = database.open()
noteOperationOutcome(true)
View
2  src/main/scala/com/twitter/querulous/database/Database.scala
@@ -57,5 +57,5 @@ trait Database {
"jdbc:mysql://" + dbhosts.mkString(",") + dbnameSegment + "?" + urlOptions
}
- def urlOptions = "useUnicode=true&characterEncoding=UTF-8"
+ def urlOptions = "useUnicode=true&characterEncoding=UTF-8&connectTimeout=500&socketTimeout=500"
}
Please sign in to comment.
Something went wrong with that request. Please try again.