1
0
Fork 0

Merge pull request #1267 from rqlite/self-remove-timeout

Reduce timeout for self-remove
master
Philip O'Toole 1 year ago committed by GitHub
commit e542c05e98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,9 @@
## 7.18.1 (unreleased)
This release also includes some small logging improvements, related to node-shutdown.
### Implementation changes and bug fixes
- [PR #1266](https://github.com/rqlite/rqlite/pull/1266): Add network information to `/status`.
- [PR #1267](https://github.com/rqlite/rqlite/pull/1267): Reduce self-remove timeout to 5 seconds.
## 7.18.0 (May 18th 2023)
This release adds a new HTTP endpoint, located at `/db/request`. This endpoint accepts both read and write requests, including mixing both together in a single request. When requests are sent to this endpoint, rqlite will automatically perform the correct operation for each SQL statement in the request. This endpoint may be more convenient for some use cases, and means that client code doesn't have to decide on whether it should send requests to `/db/execute` or `/db/query`.

@ -4,6 +4,7 @@ import (
"encoding/binary"
"io"
"net"
"strings"
"testing"
"time"
@ -213,6 +214,42 @@ func Test_ClientRemoveNode(t *testing.T) {
}
}
func Test_ClientRemoveNodeTimeout(t *testing.T) {
srv := servicetest.NewService()
srv.Handler = func(conn net.Conn) {
c := readCommand(conn)
if c == nil {
// Error on connection, so give up, as normal
// test exit can cause that too.
return
}
if c.Type != Command_COMMAND_TYPE_REMOVE_NODE {
t.Fatalf("unexpected command type: %d", c.Type)
}
rnr := c.GetRemoveNodeRequest()
if rnr == nil {
t.Fatal("expected remove node request, got nil")
}
if rnr.Id != "node1" {
t.Fatalf("unexpected node id, got %s", rnr.Id)
}
// Don't write anything, so a timeout occurs.
time.Sleep(5 * time.Second)
}
srv.Start()
defer srv.Close()
c := NewClient(&simpleDialer{}, 0)
req := &command.RemoveNodeRequest{
Id: "node1",
}
err := c.RemoveNode(req, srv.Addr(), nil, time.Second)
if err == nil || !strings.Contains(err.Error(), "i/o timeout") {
t.Fatalf("failed to receive expected error, got: %T %s", err, err)
}
}
func readCommand(conn net.Conn) *Command {
b := make([]byte, protoBufferLengthSize)
_, err := io.ReadFull(conn, b)

@ -649,5 +649,5 @@ func removeSelf(cfg *Config, str *store.Store, client *cluster.Client) error {
rn := &command.RemoveNodeRequest{
Id: cfg.NodeID,
}
return client.RemoveNode(rn, laddr, nil, 30*time.Second)
return client.RemoveNode(rn, laddr, nil, 5*time.Second)
}

Loading…
Cancel
Save