Skip to content

Commit

Permalink
Querying for data outside of existing shards should return an empty r…
Browse files Browse the repository at this point in the history
…esponse.

Fix #1004. Close #1023
  • Loading branch information
toddboom authored and jvshahid committed Oct 14, 2014
1 parent 74dad10 commit f16f4b6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- [Issue #1007](https://github.com/influxdb/influxdb/issues/1007). Return the
right content type in the response when compression is enabled
- [Issue #1004](https://github.com/influxdb/influxdb/issues/1004). Don't throw an
exception when querying for non existent data
- [Issue #722](https://github.com/influxdb/influxdb/issues/722). Add
an install target to the Makefile
- [Issue #916](https://github.com/influxdb/influxdb/issues/916). Set
Expand Down
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 f16f4b6

Please sign in to comment.