Skip to content

Commit

Permalink
Fix measurement name being double-escaped during replication
Browse files Browse the repository at this point in the history
Fixes #3708 #3704
  • Loading branch information
jwilder committed Aug 18, 2015
1 parent 8de66eb commit 95d6eaf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ There are breaking changes in this release. Please see the *Features* section be
- [#3673](https://github.com/influxdb/influxdb/pull/3673): Improve query performance by removing unnecessary tagset sorting.
- [#3676](https://github.com/influxdb/influxdb/pull/3676): Improve query performance by memomizing mapper output keys.
- [#3687](https://github.com/influxdb/influxdb/issues/3687): Fix panic: runtime error: makeslice: len out of range in hinted handoff
- [#3708](https://github.com/influxdb/influxdb/issues/3708): Fix double escaping measurement name during cluster replication
- [#3704](https://github.com/influxdb/influxdb/issues/3704): cluster replication issue for measurement name containing backslash


## v0.9.2 [2015-07-24]

Expand Down
4 changes: 3 additions & 1 deletion tsdb/points.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,9 @@ func (p *point) Tags() Tags {
}

func MakeKey(name []byte, tags Tags) []byte {
return append(escape(name), tags.HashKey()...)
// unescape the name and then re-escape it to avoid double escaping.
// The key should always be stored in escaped form.
return append(escape(unescape(name)), tags.HashKey()...)
}

// SetTags replaces the tags for the point
Expand Down
19 changes: 19 additions & 0 deletions tsdb/points_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1216,3 +1216,22 @@ func TestNewPointUnhandledType(t *testing.T) {
t.Errorf("NewPoint().String() mismatch.\ngot %v\nexp %v", pt.String(), exp)
}
}

func TestMakeKeyEscaped(t *testing.T) {
if exp, got := `cpu\ load`, tsdb.MakeKey([]byte(`cpu\ load`), tsdb.Tags{}); string(got) != exp {
t.Errorf("MakeKey() mismatch.\ngot %v\nexp %v", got, exp)
}

if exp, got := `cpu\ load`, tsdb.MakeKey([]byte(`cpu load`), tsdb.Tags{}); string(got) != exp {
t.Errorf("MakeKey() mismatch.\ngot %v\nexp %v", got, exp)
}

if exp, got := `cpu\,load`, tsdb.MakeKey([]byte(`cpu\,load`), tsdb.Tags{}); string(got) != exp {
t.Errorf("MakeKey() mismatch.\ngot %v\nexp %v", got, exp)
}

if exp, got := `cpu\,load`, tsdb.MakeKey([]byte(`cpu,load`), tsdb.Tags{}); string(got) != exp {
t.Errorf("MakeKey() mismatch.\ngot %v\nexp %v", got, exp)
}

}

0 comments on commit 95d6eaf

Please sign in to comment.