Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory

object PlaybackToSecondary {
type SuperUniverse[CT, CV] = Universe[CT, CV] with Commitable with
SecondaryStoresConfigProvider with
SecondaryManifestProvider with
SecondaryMetricsProvider with
DatasetMapReaderProvider with
Expand Down Expand Up @@ -679,13 +680,25 @@ class PlaybackToSecondary[CT, CV](u: PlaybackToSecondary.SuperUniverse[CT, CV],
}
}

def dsInfoOf(datasetId: DatasetId) = {
u.secondaryStoresConfig.lookup(secondary.storeId) match {
case Some(config) if config.isFeedback =>
logger.info("Non-exclusive resync")
u.datasetMapReader.datasetInfo(datasetId, repeatableRead = true)
case _ =>
logger.info("exclusive resync")
u.datasetMapWriter.datasetInfo(datasetId, datasetLockTimeout, semiExclusive = true)
}
}

def resync(): Unit = {
val mostRecentlyUpdatedCopyInfo = retrying[Option[metadata.CopyInfo]]({
timingReport("resync", "dataset" -> datasetId) {
u.commit() // all updates must be committed before we can change the transaction isolation level
val r = u.datasetMapReader
r.datasetInfo(datasetId, repeatableRead = true) match {
// transaction isolation level is now set to REPEATABLE READ
val w = u.datasetMapWriter
dsInfoOf(datasetId) match {
// transaction isolation level is now set to REPEATABLE READ or we have a lock on the dataset
case Some(datasetInfo) =>
val allCopies = r.allCopies(datasetInfo).toSeq.sortBy(_.dataVersion)
val mostRecentCopy =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ package com.socrata.datacoordinator.secondary

import org.joda.time.DateTime

case class SecondaryConfigInfo(storeId: String, nextRunTime: DateTime, runIntervalSeconds: Int, groupName: String)
case class SecondaryConfigInfo(
storeId: String,
nextRunTime: DateTime,
runIntervalSeconds: Int,
groupName: String,
isFeedback: Boolean
)

trait SecondaryStoresConfig {
def lookup(storeId: String): Option[SecondaryConfigInfo]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SqlSecondaryStoresConfig(conn: Connection, timingReport: TimingReport) ext

def lookup(storeId: String): Option[SecondaryConfigInfo] = {
val sql = """
SELECT store_id, next_run_time, interval_in_seconds, group_name
SELECT store_id, next_run_time, interval_in_seconds, group_name, is_feedback_secondary
FROM secondary_stores_config
WHERE store_id = ?""".stripMargin

Expand All @@ -26,7 +26,8 @@ class SqlSecondaryStoresConfig(conn: Connection, timingReport: TimingReport) ext
rs.getString("store_id"),
new DateTime(rs.getTimestamp("next_run_time").getTime),
rs.getInt("interval_in_seconds"),
Option(rs.getString("group_name")).getOrElse("")))
Option(rs.getString("group_name")).getOrElse(""),
rs.getBoolean("is_feedback_secondary")))
} else {
None
}
Expand Down