Skip to content

Commit

Permalink
Fix #1004. Querying for data outside of existing shards should return…
Browse files Browse the repository at this point in the history
… an empty response.
  • Loading branch information
toddboom committed Oct 12, 2014
1 parent e27cba0 commit a73b84f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (self *Coordinator) runQuerySpec(querySpec *parser.QuerySpec, p engine.Proc
}

if len(shards) == 0 {
return fmt.Errorf("Couldn't look up columns")
return processor.Close()
}

shardConcurrentLimit := self.config.ConcurrentShardQueryLimit
Expand Down
34 changes: 34 additions & 0 deletions integration/single_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,40 @@ func (self *SingleServerSuite) TestDataResurrectionAfterRestart(c *C) {
c.Assert(series[0].Points, HasLen, 0)
}

func (self *SingleServerSuite) TestEmptyResponseWhenNoShardsMatchQuery(c *C) {
rootUser := self.server.GetClient("", c)

rootUser.CreateDatabase("db")

c.Assert(rootUser.CreateDatabaseUser("db", "user", "pass"), IsNil)

config := &influxdb.ClientConfig{
Username: "user",
Password: "pass",
Database: "db",
}

user, _ := influxdb.NewClient(config)

data := `
[
{
"points": [
[1]
],
"name": "test_should_write",
"columns": ["value"]
}
]`

series := []*influxdb.Series{}
c.Assert(json.Unmarshal([]byte(data), &series), IsNil)
c.Assert(user.WriteSeries(series), IsNil)

failing_content := self.server.RunQueryAsRoot("select * from test_should_write where time > '1990-12-01' and time < '1990-12-12'", "m", c)
c.Assert(failing_content, HasLen, 0)
}

// issue https://github.com/influxdb/influxdb/issues/702. Dropping shards can cause server crash
// Two cases here. First is they try to drop the same shard multiple times. Second is that
// they drop a shard and the server gets restarted so the raft log replays and tries to drop it again.
Expand Down

0 comments on commit a73b84f

Please sign in to comment.