-
Notifications
You must be signed in to change notification settings - Fork 712
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
Problems quering from other nodes #295
Comments
Thanks for your report.
Sending dot-commands like As for your other issue, I cannot reproduce it. I built the latest source on MacOX and repeated your steps of connecting to the leader, and then connecting to a different node. I also tested the latest release. It all works fine.
|
Be sure you are running |
Execute |
If I had to guess, I'd say you're not running the version of rqlited you think you're running. It almost looks like you're still running older software. The status commands will show you the version each node is running. |
Hi, the process i follow to run the software is just clone the master branch from github, the run get -d ./... , and after that go install ./..., And this is the output from all the running nodes. host in port 4001 |
Nothing looks wrong with the output. I see you are running Linux, so perhaps you can rule out something wrong with your build by running a pre-built binary. You can download v3.12.1 at https://github.com/rqlite/rqlite/releases Follow the instructions for Linux, and show me exactly what you do. Right now I cannot repro this issue. https://gist.github.com/otoolep/80dd3ac5a53bc9ecc5acd91d45a67aa6 shows me running two v3.12.1 nodes, the nodes forming a cluster, and connecting to each node via the CLI and executing |
Looks like i have troubles with my environment and building the rqlite from source code. So i went back to the 3.12.0 version and built it again but same thing happens. I tried to download the latest release from https://github.com/rqlite/rqlite/releases and unfortunately the same thing happens. I will try to run this on other computer, and i will let you know about it. Thanks for your quick answer. |
You will need to show me as detailed a sequence of events demonstrating the problem, as I showed on the gist link above (which shows everything to be fine). As far as I can see there is nothing wrong with the software. |
Ok i tried with a new docker and this is the full process https://gist.github.com/anfho93/fa6cbed9f56a61b9201e79c1d3dfec97 |
Thanks.
Can you please do it again, but with the prebuilt 3.12.1 release? You can download the binary and just run it without building anything.
… On Mar 17, 2017, at 9:18 PM, anfho93 ***@***.***> wrote:
Ok i tried with a new docker and this is the full process
https://gist.github.com/anfho93/fa6cbed9f56a61b9201e79c1d3dfec97
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I wonder if it's a Go version 1.8 thing, which you use to build it. Can you also rebuilding with Go 1.7. The prebuilt binaries are built with 1.7.1 so that is why I would like you to try them.
… On Mar 17, 2017, at 9:18 PM, anfho93 ***@***.***> wrote:
Ok i tried with a new docker and this is the full process
https://gist.github.com/anfho93/fa6cbed9f56a61b9201e79c1d3dfec97
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
This is the full process downloading the prebuilt binaries https://gist.github.com/anfho93/1960026cb8550283b6729c7a98d68fcf And it works, the funny fact is that a couple of days ago it was working with go1.8. |
I will try to re build it with go 1.7.1 and i will let you know |
I will see if I can repro after building with 1.8. |
There were changes in HTTP redirect handling between 1.7 and 1.8. I had to make one change to account for it: #289 Perhaps there is another place that needs changing. |
OK, I can repro this when I build the system with 1.8. I'm looking into a fix. |
Thanks a lot. |
@anfho93 -- I believe this is now fixed on master. Do you want to pull down the latest code on master, build with Go 1.8, and see if it works now? If so, we can close this issue. |
Works perfectly now, thank you so much @otoolep |
Thank you @anfho93 for the report -- there was a real bug here. Glad it's fixed. |
Hi, I ran into the exact same issue. I build it from the sources using go1.9 on my Raspberry Pi 3 (ARM). I used the source code at commit 2eb02dc on branch master (last commit up to now). At the end is the result of I will try it with go1.8 and report later. I don't know a single thing about go, but if you have bugs everytime you try to upgrade your version without a single warning... Well I don't want to know more about it.
|
Ok, I'm a bit confused here. I tried the following combinations and none worked :
With commit 2eb02dc All give the same result :
I am guessing I am not compiling it the way I should, even if I am following the steps of package.sh with very few modifications because the releases indeed work like they should :
I am interested in knowing what I am doing wrong because I would like to compile it on ARM, even though I can't figure out what is wrong even for AMD. |
Don't mind me. I got it working with v4.3.0 77e345b |
OK, thanks @wil222 -- I'll take a look at top of tree, which is in active development. |
Re-opening so I take a look for 5.0. |
This issue also occurs in rqlite-v5.0 on windows 8 x86_64. The bugs are at github.com/rqlite/rqlite/cmd/rqlite/query.go makeQueryRequest() and github.com/rqlite/rqlite/http/service.go handleQuery(): // github.com/rqlite/rqlite/cmd/rqlite/query.go makeQueryRequest()
func makeQueryRequest(line string) func(string) (*http.Request, error) {
requestData := strings.NewReader(makeJSONBody(line))
return func(urlStr string) (*http.Request, error) {
req, err := http.NewRequest("POST", urlStr, requestData)
if err != nil {
return nil, err
}
return req, nil
}
}
// github.com/rqlite/rqlite/http/service.go handleQuery()
var resp Response
results, err := queryer.Query(&store.QueryRequest{queries, timings, isAtomic, lvl})
if err != nil {
if err == store.ErrNotLeader {
leader := s.leaderAPIAddr()
if leader == "" {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return
}
// - little-pan Bug-fix: should restore the shifted path.
r.URL.Path = "/db/query"
// - little-pan
redirect := s.FormRedirect(r, leader)
// - little-pan
s.logger.Printf("query: redirect to %s", redirect)
http.Redirect(w, r, redirect, http.StatusMovedPermanently)
return The requestData is a Reader, shouldn't be read many times in the returned func! And only jsonBody string can be reused.A fix method may be: func makeQueryRequest(line string) func(string) (*http.Request, error) {
//Bug-fix: requestData is a Reader, shouldn't be read many times!
//And only jsonBody string can be reused.
// @since 2019-01-26 little-pan
//requestData := strings.NewReader(makeJSONBody(line))
jsonBody := makeJSONBody(line)
return func(urlStr string) (*http.Request, error) {
requestData := strings.NewReader(jsonBody)
req, err := http.NewRequest("POST", urlStr, requestData)
if err != nil {
return nil, err
}
return req, nil
}
} |
@Little-Pan -- I don't the problem with the code you point at. Exactly where is the reader called multiple times? |
@otoolep There are many bugs here. The first, the result func of makeQueryRequest() is called multiple times when the rqlited follower node returns http 302(eg. this node not the leader). And another bug(such issues also in other http api implementations) exists in following function: // github.com/rqlite/rqlite/http/service.go handleQuery()
var resp Response
results, err := queryer.Query(&store.QueryRequest{queries, timings, isAtomic, lvl})
if err != nil {
if err == store.ErrNotLeader {
leader := s.leaderAPIAddr()
if leader == "" {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return
}
// - little-pan Bug-fix: should restore the shifted path here.
r.URL.Path = "/db/query"
redirect := s.FormRedirect(r, leader)
// - little-pan
s.logger.Printf("query: redirect to %s", redirect)
http.Redirect(w, r, redirect, http.StatusMovedPermanently)
return
// ... When s.FormRedirect(r, leader) called in the handleQuery() func, the r.URL.Path(has been shifted in the front handler steps) doesn't be restored to original request URL path, then set as Location header of http redirection. This way can lead to "ERR! unexpected end of JSON input"(status code http 400 actually), because of the Location header of http redirection has been truncated and incorrect. |
And no such issues are in rqlite v4.4.0(http api implementation relatively simple and stable), but the redirection is a bit slow in windows 8 x86_64(the performation issue not in centos 7 x86_64). |
OK, I'll take look when I return to the code -- thanks. |
No known issues in 5.x. |
Hi. I'm having problems with the cluster connection, im following the steps in the documentation, and when I connect directly to the leader through rqlite cmd and execute queries everything is ok, but when i do the same thing from other nodes, the answer to all the queries is:
ERR! unexpected end of JSON input
I thinks this is related to the recent changes made. because i use curl to make a query in a non-leader node and this is what i get:
curl -G 'localhost:4003/db/query?pretty&timings' --data-urlencode 'q=.tables'
Moved Permanently.
btw, this is my configuration :
rqlited ./node.1
rqlited -http localhost:4003 -raft localhost:4004 -join http://localhost:4001 ./node.2
rqlited -http localhost:4005 -raft localhost:4006 -join http://localhost:4001 ./node.3
This is my first step on the leader node
$ rqlite
127.0.0.1:4001> CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT)
0 row affected (0.000668 sec)
127.0.0.1:4001> .schema
+-----------------------------------------------------------------------------+
| sql |
+-----------------------------------------------------------------------------+
| CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT) |
+-----------------------------------------------------------------------------+
127.0.0.1:4001> INSERT INTO foo(name) VALUES("fiona")
1 row affected (0.000080 sec)
127.0.0.1:4001> SELECT * FROM foo
+----+-------+
| id | name |
+----+-------+
| 1 | fiona |
+----+-------+
When i try to do the same on a non-leader node, this is the answer
$ rqlite -H localhost -p 4003
localhost:4003> .schema
ERR! unexpected end of JSON input
I tried to make a curl request and this is what i get
$ curl -G 'localhost:4003/db/query?pretty&timings' --data-urlencode 'q=select * from foo'
Moved Permanently.
This behavior was not present on the previous releases. I hope you can help me with this.
The text was updated successfully, but these errors were encountered: