Skip to content
Browse files

calling mergeinfotable from shardcoordinator

  • Loading branch information...
1 parent ae9f535 commit 9bd8cad195708a5aa3d436e9f962a4a522906885 @ssandler ssandler committed Feb 4, 2013
View
7 TeslaSQL/Agents/ShardCoordinator.cs
@@ -178,7 +178,14 @@ public ShardCoordinator(IDataUtils dataUtils, Logger logger)
private void ConsolidateInfoTables(ChangeTrackingBatch batch) {
logger.Log("Consolidating info tables", LogLevel.Debug);
var rowCounts = GetRowCounts(Config.Tables, Config.RelayDB, batch.CTID);
+ //publish table info with actual rowcounts for the tables that had changes
PublishTableInfo(tablesWithChanges, Config.RelayDB, rowCounts, batch.CTID);
+ //pull in the table info for tables that didn't have changes from the shard databases
+ //start with the master shard database first because it is assumed to have the
+ //most up to date schema information
+ foreach (var sd in shardDatabases.OrderBy(d => d == Config.MasterShard ? 0 : 1)) {
+ sourceDataUtils.MergeInfoTable(sd, Config.RelayDB, batch.CTID);
+ }
}
private void SetFieldList(TableConf table, string database, ChangeTrackingBatch batch) {
View
7 TeslaSQL/DataUtils/IDataUtils.cs
@@ -404,7 +404,7 @@ public interface IDataUtils {
/// associated with the given slaveIdentifier
/// </summary>
void MarkBatchesComplete(string dbName, IEnumerable<long> ctids, DateTime syncStopTime, string slaveIdentifier);
-
+
/// <summary>
/// Gets a list of all columns for the table confs passed in.
/// </summary>
@@ -418,6 +418,11 @@ public interface IDataUtils {
Dictionary<TableConf, IList<string>> GetAllPrimaryKeys(string dbName, IEnumerable<TableConf> tables, ChangeTrackingBatch batch);
Dictionary<TableConf, IEnumerable<string>> GetAllPrimaryKeysMaster(string database, IEnumerable<TableConf> tableConfss);
+
+ /// <summary>
+ /// Merge rows from a shard's tblCTTableInfo_<CTID> into the consolidated DB (for tables that didn't have changes)
+ /// </summary>
+ void MergeInfoTable(string shardDB, string consolidatedDB, long CTID);
}
public struct TTable {
public readonly string name;
View
2 TeslaSQL/DataUtils/MSSQLDataUtils.cs
@@ -974,7 +974,7 @@ THEN DELETE
@"DELETE a FROM [{0}] a
WHERE EXISTS (
SELECT 1 FROM [{0}] b WHERE {1} AND (a.sys_change_version < b.sys_change_version
- OR (a.sys_change_version = b.sys_change_version AND a.[Tesla_Unique_ID] < b.[Tesla_Unique_ID]))
+ OR (a.sys_change_version = b.sys_change_version AND a.[Tesla_Unique_ID] < b.[Tesla_Unique_ID]))
) ",
consolidatedTableName, whereCondition);
SqlNonQuery(dbName, new SqlCommand(delete));
View
4 TeslaSQL/DataUtils/NetezzaDataUtils.cs
@@ -546,6 +546,10 @@ class InsertDelete {
public Dictionary<TableConf, IEnumerable<string>> GetAllPrimaryKeysMaster(string database, IEnumerable<TableConf> tableConfss) {
throw new NotImplementedException();
}
+
+ public void MergeInfoTable(string shardDB, string consolidatedDB, long CTID) {
+ throw new NotImplementedException();
+ }
}
}
View
6 TeslaSQL/DataUtils/TestDataUtils.cs
@@ -398,7 +398,7 @@ public class TestDataUtils : IDataUtils {
return true;
}
- public void LogError(string message,string headers) {
+ public void LogError(string message, string headers) {
return;
}
@@ -630,5 +630,9 @@ public class TestDataUtils : IDataUtils {
public Dictionary<TableConf, IEnumerable<string>> GetAllPrimaryKeysMaster(string database, IEnumerable<TableConf> tableConfss) {
throw new NotImplementedException();
}
+
+ public void MergeInfoTable(string shardDB, string consolidatedDB, long CTID) {
+ throw new NotImplementedException();
+ }
}
}

0 comments on commit 9bd8cad

Please sign in to comment.
Something went wrong with that request. Please try again.