From 8646cb5a42184fb237c05bc84ce2c8199472d3d4 Mon Sep 17 00:00:00 2001 From: Shugo Maeda Date: Thu, 17 Jul 2014 14:13:15 +0900 Subject: [PATCH] The attributes of a shard space should not be reverted to the defalut values when writing data into the shard space. --- cluster/cluster_configuration.go | 6 ++++++ integration/single_server_test.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/cluster/cluster_configuration.go b/cluster/cluster_configuration.go index 4fe84190fa..2b583e4279 100644 --- a/cluster/cluster_configuration.go +++ b/cluster/cluster_configuration.go @@ -1290,6 +1290,12 @@ func (self *ClusterConfiguration) removeShard(shard *ShardData) { } func (self *ClusterConfiguration) AddShardSpace(space *ShardSpace) error { + if space.Name != DEFAULT_SHARD_SPACE_NAME { + err := space.Validate(self) + if err != nil { + return err + } + } self.shardLock.Lock() defer self.shardLock.Unlock() databaseSpaces := self.databaseShardSpaces[space.Database] diff --git a/integration/single_server_test.go b/integration/single_server_test.go index 5c42bb6b27..7fe3363115 100644 --- a/integration/single_server_test.go +++ b/integration/single_server_test.go @@ -740,6 +740,11 @@ func (self *SingleServerSuite) TestCreateShardSpace(c *C) { spaces, err = client.GetShardSpaces() c.Assert(err, IsNil) c.Assert(self.hasSpace("db1", "month", spaces), Equals, true) + for _, s := range spaces { + if s.Name == "month" && s.Database == "db1" { + c.Assert(s.Regex, Equals, "/^the_dude_abides/") + } + } shards, err := client.GetShards() c.Assert(err, IsNil) spaceShards := self.getShardsForSpace("month", shards.All)