nickdu
2009-05-06 17:14:01 UTC
My managed application which runs once a day at 10:00 pm to do some
partitioning maintenance on our DB often encounters an exception. It also
sometimes succeeds. When it encounters the error it actually seems as if it
successfully added the partition boundary value yet decides to fail for some
reason. I say this because when I run the application again it shows the
boundary value exists. This application dumps out the boundary values that
exist and the partitions and # of rows in those partitions before it makes
any modifications. That's how come I can say that the boundary value was
added even though the previous run encountered an exception.
The exception I encounter is:
"Failed due to the following Error: System.Data.SqlClient.SqlException:
Duplicate range boundary values are not allowed in partition function
boundary values list. The boundary value being added is already present at
ordinal 46 of the boundary value list.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String
methodName, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult
result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
.
.
."
before doing any modifications the tool dumped the current partition
information as follows:
boundaries:
0: 3/30/2009 12:00:00 AM
1: 3/31/2009 12:00:00 AM
2: 4/1/2009 12:00:00 AM
3: 4/2/2009 12:00:00 AM
4: 4/3/2009 12:00:00 AM
5: 4/4/2009 12:00:00 AM
6: 4/5/2009 12:00:00 AM
7: 4/6/2009 12:00:00 AM
8: 4/7/2009 12:00:00 AM
9: 4/8/2009 12:00:00 AM
10: 4/9/2009 12:00:00 AM
11: 4/10/2009 12:00:00 AM
12: 4/11/2009 12:00:00 AM
13: 4/12/2009 12:00:00 AM
14: 4/13/2009 12:00:00 AM
15: 4/14/2009 12:00:00 AM
16: 4/15/2009 12:00:00 AM
17: 4/16/2009 12:00:00 AM
18: 4/17/2009 12:00:00 AM
19: 4/18/2009 12:00:00 AM
20: 4/19/2009 12:00:00 AM
21: 4/20/2009 12:00:00 AM
22: 4/21/2009 12:00:00 AM
23: 4/22/2009 12:00:00 AM
24: 4/23/2009 12:00:00 AM
25: 4/24/2009 12:00:00 AM
26: 4/25/2009 12:00:00 AM
27: 4/26/2009 12:00:00 AM
28: 4/27/2009 12:00:00 AM
29: 4/28/2009 12:00:00 AM
30: 4/29/2009 12:00:00 AM
31: 4/30/2009 12:00:00 AM
32: 5/1/2009 12:00:00 AM
33: 5/2/2009 12:00:00 AM
34: 5/3/2009 12:00:00 AM
35: 5/4/2009 12:00:00 AM
36: 5/5/2009 12:00:00 AM
37: 5/6/2009 12:00:00 AM
38: 5/7/2009 12:00:00 AM
39: 5/8/2009 12:00:00 AM
40: 5/9/2009 12:00:00 AM
41: 5/10/2009 12:00:00 AM
42: 5/11/2009 12:00:00 AM
43: 5/12/2009 12:00:00 AM
44: 5/13/2009 12:00:00 AM
45: 5/14/2009 12:00:00 AM
partitions:
0: 232
1: 8
2: 9
3: 11
4: 11
5: 11
6: 11
7: 11
8: 42
9: 22
10: 13
11: 13
12: 13
13: 12
14: 13
15: 13
16: 15
17: 16
18: 18
19: 16
20: 18
21: 16
22: 17
23: 28
24: 29
25: 41
26: 37
27: 44
28: 20
29: 23
30: 71
31: 75
32: 224475
33: 631345
34: 134608
35: 130413
36: 649225
37: 640533
38: 0
39: 0
40: 0
41: 0
42: 0
43: 0
44: 0
45: 0
46: 0
The part that failed was the code which attempted to add another future day,
5/15/2009. However when I run the tool again it shows that boundary value
5/15/2009 exists and my tool is the only code which should be modifying the
partitions.
The code I use to add a boundary value is:
private void AddBoundary(DateTime date)
{
string sql = "alter partition scheme SlidingWindow NEXT USED [Data] " +
"alter partition function SlidingWindow() split range('{0}')";
sql = string.Format(sql, date.ToString("yyyy-MM-dd"));
Db.ExecuteNonQuery(this._connection, sql, 60);
}
Is there a known reason why this would succeed yet still throw an exception
indicating it failed?
partitioning maintenance on our DB often encounters an exception. It also
sometimes succeeds. When it encounters the error it actually seems as if it
successfully added the partition boundary value yet decides to fail for some
reason. I say this because when I run the application again it shows the
boundary value exists. This application dumps out the boundary values that
exist and the partitions and # of rows in those partitions before it makes
any modifications. That's how come I can say that the boundary value was
added even though the previous run encountered an exception.
The exception I encounter is:
"Failed due to the following Error: System.Data.SqlClient.SqlException:
Duplicate range boundary values are not allowed in partition function
boundary values list. The boundary value being added is already present at
ordinal 46 of the boundary value list.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet
bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String
methodName, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult
result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
.
.
."
before doing any modifications the tool dumped the current partition
information as follows:
boundaries:
0: 3/30/2009 12:00:00 AM
1: 3/31/2009 12:00:00 AM
2: 4/1/2009 12:00:00 AM
3: 4/2/2009 12:00:00 AM
4: 4/3/2009 12:00:00 AM
5: 4/4/2009 12:00:00 AM
6: 4/5/2009 12:00:00 AM
7: 4/6/2009 12:00:00 AM
8: 4/7/2009 12:00:00 AM
9: 4/8/2009 12:00:00 AM
10: 4/9/2009 12:00:00 AM
11: 4/10/2009 12:00:00 AM
12: 4/11/2009 12:00:00 AM
13: 4/12/2009 12:00:00 AM
14: 4/13/2009 12:00:00 AM
15: 4/14/2009 12:00:00 AM
16: 4/15/2009 12:00:00 AM
17: 4/16/2009 12:00:00 AM
18: 4/17/2009 12:00:00 AM
19: 4/18/2009 12:00:00 AM
20: 4/19/2009 12:00:00 AM
21: 4/20/2009 12:00:00 AM
22: 4/21/2009 12:00:00 AM
23: 4/22/2009 12:00:00 AM
24: 4/23/2009 12:00:00 AM
25: 4/24/2009 12:00:00 AM
26: 4/25/2009 12:00:00 AM
27: 4/26/2009 12:00:00 AM
28: 4/27/2009 12:00:00 AM
29: 4/28/2009 12:00:00 AM
30: 4/29/2009 12:00:00 AM
31: 4/30/2009 12:00:00 AM
32: 5/1/2009 12:00:00 AM
33: 5/2/2009 12:00:00 AM
34: 5/3/2009 12:00:00 AM
35: 5/4/2009 12:00:00 AM
36: 5/5/2009 12:00:00 AM
37: 5/6/2009 12:00:00 AM
38: 5/7/2009 12:00:00 AM
39: 5/8/2009 12:00:00 AM
40: 5/9/2009 12:00:00 AM
41: 5/10/2009 12:00:00 AM
42: 5/11/2009 12:00:00 AM
43: 5/12/2009 12:00:00 AM
44: 5/13/2009 12:00:00 AM
45: 5/14/2009 12:00:00 AM
partitions:
0: 232
1: 8
2: 9
3: 11
4: 11
5: 11
6: 11
7: 11
8: 42
9: 22
10: 13
11: 13
12: 13
13: 12
14: 13
15: 13
16: 15
17: 16
18: 18
19: 16
20: 18
21: 16
22: 17
23: 28
24: 29
25: 41
26: 37
27: 44
28: 20
29: 23
30: 71
31: 75
32: 224475
33: 631345
34: 134608
35: 130413
36: 649225
37: 640533
38: 0
39: 0
40: 0
41: 0
42: 0
43: 0
44: 0
45: 0
46: 0
The part that failed was the code which attempted to add another future day,
5/15/2009. However when I run the tool again it shows that boundary value
5/15/2009 exists and my tool is the only code which should be modifying the
partitions.
The code I use to add a boundary value is:
private void AddBoundary(DateTime date)
{
string sql = "alter partition scheme SlidingWindow NEXT USED [Data] " +
"alter partition function SlidingWindow() split range('{0}')";
sql = string.Format(sql, date.ToString("yyyy-MM-dd"));
Db.ExecuteNonQuery(this._connection, sql, 60);
}
Is there a known reason why this would succeed yet still throw an exception
indicating it failed?
--
Thanks,
Nick
***@community.nospam
remove "nospam" change community. to msn.com
Thanks,
Nick
***@community.nospam
remove "nospam" change community. to msn.com