Permalink
Browse files

fixing some bugs in initialization script, removing parallelism from …

…it because it was just too buggy
  • Loading branch information...
1 parent e410a1f commit 4cfd010d6979154b68022ddb4040cf21acaeef47 @ssandler ssandler committed Feb 7, 2013
Showing with 10 additions and 12 deletions.
  1. +8 −6 scripts/AddTable-ToCT.ps1
  2. +2 −6 scripts/Initialize-DB.ps1
View
@@ -39,6 +39,7 @@ If ("MSSQL","Netezza" -NotContains $slavetype) {
}
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
+[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") | out-null
# Load DB module from current directory
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
Import-Module .\Modules\DB
@@ -50,11 +51,11 @@ $error.clear()
if ($slavetype -eq "Netezza") {
set-alias plink $plinkpath
- $bcppath = $bcppath.TrimEnd("\") + $slavedb.ToLower()
+ $bcppath = $bcppath.TrimEnd("\") + "\" + $slavedb.ToLower()
if (!(Test-path $bcppath)) {
mkdir $bcppath | out-null
}
- $bcppath += $table.ToLower() + ".txt"
+ $bcppath += "\" + $table.ToLower() + ".txt"
}
#set column lists for slave if they are specified
@@ -132,7 +133,7 @@ Function Invoke-Slave($query) {
if ($slavetype -eq "MSSQL") {
Invoke-SqlCmd2 -serverinstance $slave -database $slavedb -query $query
} elseif ($slavetype -eq "Netezza") {
- Invoke-NetezzaQuery -serverinstance $slave -database $slavedb -query $query -user $username -password $password
+ Invoke-NetezzaQuery -serverinstance $slave -database $slavedb -query $query -user $user -password $password
}
}
@@ -194,7 +195,7 @@ if ($slavetype -eq "Netezza") {
$con.Connect()
$server = new-object ("Microsoft.SqlServer.Management.Smo.Server") $con
$database = $server.Databases[$masterdb]
- $smotable = $Database.Tables.Item($table)
+ $smotable = $Database.Tables.Item($table, $schema)
$cols = @()
$colexpressions = @()
@@ -203,12 +204,13 @@ if ($slavetype -eq "Netezza") {
$typename = $column.DataType.Name
$moddatatype = [TeslaSQL.DataType]::MapDataType("MSSQL", "Netezza", $typename)
if ($typename -ne $moddatatype) {
- $col = (Map-ReservedWordNetezza $column.Name) + " " + $typename
+ $col = (Map-ReservedWordNetezza $column.Name) + " " + $moddatatype
if ($column.Nullable) {
$col += " NULL"
} else {
$col += " NOT NULL"
}
+ $cols += $col
$colexpressions += Get-ColExpression (Map-ReservedWordNetezza $column.Name) $column.DataType
continue
}
@@ -435,7 +437,7 @@ if ($slavetype -eq "MSSQL") {
#if we are initializing multiple slaves we should only update tblCTInitialize when the last one is done
-if (!$notlast) {
+if (!$notlast -and !$error) {
$query = "update tblCTInitialize
set inifinishtime = getdate(), inprogress = 0
where tablename = '$table'"
@@ -56,9 +56,6 @@ for this to work.
Skips prompts for confirmation that occur before dropping all tables on a CT database. Use this
flag only if you're sure the database names in your config file are correct. Also skips prompt
that confirms the intentions of this script at the beginning.
-.PARAMETER maxthreads
-When initializing more than one table, table initialization happens in parallel. This parameter configures
-the maximum number of threads to use. The default is 2.
.INPUTS
You cannot pipe objects to Initialize-DB.
.OUTPUTS
@@ -103,8 +100,7 @@ Param(
[switch]$notlastslave,
[switch]$notfirstshard,
[switch]$reinitialize,
- [switch]$yes,
- [Parameter(Mandatory=$false)][int]$maxthreads=2
+ [switch]$yes
)
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
Import-Module .\Modules\DB
@@ -652,7 +648,7 @@ foreach ($tableconf in $tables.SelectNodes("table")) {
}
#initialize tables in parallel with a configurable throttle
-$tablestoinitialize | Invoke-Parallel -Throttle $maxthreads {
+$tablestoinitialize | Foreach-Object {
Write-Host ("Calling .\AddTable-ToCT for table " + $_.table)
#switch to directory containing the script. required because this is inside a runspace which
#doesn't inherit the environment of the parent scope.

0 comments on commit 4cfd010

Please sign in to comment.