Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix points write panic #4591

Closed
wants to merge 2 commits into from
Closed

fix points write panic #4591

wants to merge 2 commits into from

Conversation

oiooj
Copy link
Contributor

@oiooj oiooj commented Oct 28, 2015

fix index out of range risk, log here:

[wal] 2015/10/28 11:39:55 write to index of partition 1 took 3.516488ms
[wal] 2015/10/28 11:40:05 Flush due to idle. Flushing 8 series with 8 points and 424 bytes from partition 1
[wal] 2015/10/28 11:40:05 write to index of partition 1 took 3.126415ms
[wal] 2015/10/28 11:40:15 Flush due to idle. Flushing 8 series with 8 points and 424 bytes from partition 1
[wal] 2015/10/28 11:40:15 write to index of partition 1 took 1.716188ms
[http] 2015/10/28 11:40:25 221.221.221.98 - - [28/Oct/2015:11:40:25 +0800] POST /write HTTP/1.1 400 57 - Mozilla/5.0 (Macintosh; Intel Mac 
OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36 9facaff5-7d25-11e5-8001-000000000000 2.522487ms
[wal] 2015/10/28 11:40:25 Flush due to idle. Flushing 8 series with 8 points and 424 bytes from partition 1
[wal] 2015/10/28 11:40:25 write to index of partition 1 took 12.511171ms
[wal] 2015/10/28 11:40:35 Flush due to idle. Flushing 8 series with 8 points and 442 bytes from partition 1
[wal] 2015/10/28 11:40:35 write to index of partition 1 took 7.997816ms
[http] 2015/10/28 11:40:38 221.221.221.98 - - [28/Oct/2015:11:40:38 +0800] POST /write HTTP/1.1 400 45 - Mozilla/5.0 (Macintosh; Intel Mac 
OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36 a776548d-7d25-11e5-8002-000000000000 19.391701ms
[wal] 2015/10/28 11:40:45 Flush due to idle. Flushing 8 series with 8 points and 442 bytes from partition 1
[wal] 2015/10/28 11:40:45 write to index of partition 1 took 1.890025ms
[http] 2015/10/28 11:40:50 221.221.221.98 - - [28/Oct/2015:11:40:50 +0800] POST /write HTTP/1.1 200 23 - Mozilla/5.0 (Macintosh; Intel Mac 
OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36 af16a5b9-7d25-11e5-8003-000000000000 1.222898ms [pan
ic:runtime error: index out of range]

pull from remote master
@otoolep
Copy link
Contributor

otoolep commented Oct 28, 2015

@oiooj -- can you please run the test suite locally before pushing up any further commits? That way you will get the quickest turnaround when debugging your code.

@oiooj
Copy link
Contributor Author

oiooj commented Oct 28, 2015

@otoolep sure, I have ran the test file.

$ go test points_test.go 
ok      command-line-arguments  0.013s

$ go test handler_test.go 
ok      command-line-arguments  0.019s

It is right ?

@otoolep
Copy link
Contributor

otoolep commented Oct 28, 2015

I don't know, depends if you are in the correct directory.

$ ls
balancer.go       circle-test.sh  cmd                       DOCKER.md  influxql                    Makefile  nightly.sh  README.md  snapshot  test-32bit-docker.sh  uuid
balancer_test.go  circle.yml      CONTRIBUTING.md           errors.go  influxvar.go                meta      package.sh  scripts    statik    tests
build-docker.sh   client          Dockerfile                etc        LICENSE                     models    pkg         services   stress    toml
CHANGELOG.md      cluster         Dockerfile_test_ubuntu32  importer   LICENSE_OF_DEPENDENCIES.md  monitor   QUERIES.md  shared     tcp       tsdb
$ cd models/
$ go test -run TestParsePointNoValue
PASS
ok      github.com/influxdb/influxdb/models     0.001s

will run the test that is failing on Circle.

@oiooj
Copy link
Contributor Author

oiooj commented Oct 28, 2015

No problem here, I don't know what's going on. Always failed on Circle.

Sosara@MBA:~/golang/src/github.com/oiooj/influxdb/models$ go test -run TestParsePointNoValue
PASS
ok      github.com/oiooj/influxdb/models        0.010s

and the circle-test.sh

...
--- PASS: TestWAL_Cursor_Reverse (0.00s)
PASS
ok      github.com/influxdb/influxdb/tsdb/engine/wal    0.949s
?       github.com/influxdb/influxdb/tsdb/internal  [no test files]

? github.com/influxdb/influxdb/uuid [no test files] bash circle-test.sh returned exit code 1

@oiooj
Copy link
Contributor Author

oiooj commented Oct 28, 2015

@otoolep fixed , Thanks

@otoolep
Copy link
Contributor

otoolep commented Oct 28, 2015

Thanks @oiooj.

Can you please rebase and squash the commits, with a single commit?

@otoolep
Copy link
Contributor

otoolep commented Oct 28, 2015

Can you also add a test case for this? We really need test cases for every change.

@oiooj
Copy link
Contributor Author

oiooj commented Oct 28, 2015

rebased the commits , I reviewed handler_test.go source, This is a post and write data request, It's difficult to add a test case. Thanks @otoolep

@@ -461,7 +461,7 @@ func (h *Handler) serveWriteLine(w http.ResponseWriter, r *http.Request, body []
}

// check that the byte is in the standard ascii code range
if body[i] > 32 {
if body[i] > 32 || i >= len(body)-1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see what you are doing. Basically, if it's not JSON by index (len-1) (and not a valid ASCII character either), it's not JSON at all. Is that what you're getting at?

@otoolep
Copy link
Contributor

otoolep commented Oct 29, 2015

I believe I follow what this patch fixes, but I'd like a second set of eyes.

@corylanou ?

@corylanou
Copy link
Contributor

Yes this appears to make sense. We should add a test though so that we don't regress. Once a test is added, +1. Thanks!

@otoolep
Copy link
Contributor

otoolep commented Oct 30, 2015

Closing in favour #4625

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants