diff --git a/lib/gat/gatling/client/client.go b/lib/gat/gatling/client/client.go index ac6308760d411ccf3a94bfab2174472b376352d7..43d99a1dbf213da3bd61265945887985eeed7526 100644 --- a/lib/gat/gatling/client/client.go +++ b/lib/gat/gatling/client/client.go @@ -348,133 +348,6 @@ func (c *Client) handle_function(ctx context.Context, f *protocol.FunctionCall) return err } -/* -func (c *Client) handle_query(ctx context.Context, q *protocol.Query) error { - // TODO extract query and do stuff based on it - _, err := q.Write(c.server.wr) - if err != nil { - return err - } - for { - var rsp protocol.Packet - rsp, err = protocol.ReadBackend(c.server.r) - if err != nil { - return err - } - switch r := rsp.(type) { - case *protocol.ReadyForQuery: - if r.Fields.Status == 'I' { - _, err = r.Write(c.wr) - if err != nil { - return err - } - return nil - } - case *protocol.CopyInResponse, *protocol.CopyOutResponse, *protocol.CopyBothResponse: - err = c.handle_copy(ctx, rsp) - if err != nil { - return err - } - continue - } - _, err = rsp.Write(c.wr) - if err != nil { - return err - } - } -} - -func (c *Client) handle_function(ctx context.Context, f *protocol.FunctionCall) error { - _, err := f.Write(c.wr) - if err != nil { - return err - } - for { - var rsp protocol.Packet - rsp, err = protocol.ReadBackend(c.server.r) - if err != nil { - return err - } - _, err = rsp.Write(c.wr) - if err != nil { - return err - } - if r, ok := rsp.(*protocol.ReadyForQuery); ok { - if r.Fields.Status == 'I' { - break - } - } - } - - return nil -} - -func (c *Client) handle_copy(ctx context.Context, p protocol.Packet) error { - _, err := p.Write(c.wr) - if err != nil { - return err - } - switch p.(type) { - case *protocol.CopyInResponse: - outer: - for { - var rsp protocol.Packet - rsp, err = protocol.ReadFrontend(c.r) - if err != nil { - return err - } - // forward packet - _, err = rsp.Write(c.server.wr) - if err != nil { - return err - } - - switch rsp.(type) { - case *protocol.CopyDone, *protocol.CopyFail: - break outer - } - } - return nil - case *protocol.CopyOutResponse: - for { - var rsp protocol.Packet - rsp, err = protocol.ReadBackend(c.server.r) - if err != nil { - return err - } - // forward packet - _, err = rsp.Write(c.wr) - if err != nil { - return err - } - - switch r := rsp.(type) { - case *protocol.CopyDone: - return nil - case *protocol.ErrorResponse: - e := new(error2.Error) - e.Read(r) - return e - } - } - case *protocol.CopyBothResponse: - // TODO fix this filthy hack, instead of going in parallel (like normal), read fields serially - err = c.handle_copy(ctx, new(protocol.CopyInResponse)) - if err != nil { - return err - } - err = c.handle_copy(ctx, new(protocol.CopyOutResponse)) - if err != nil { - return err - } - return nil - default: - panic("unreachable") - } -} - -*/ - func (c *Client) Send(pkt protocol.Packet) error { _, err := pkt.Write(c.wr) return err diff --git a/lib/gat/gatling/conn_pool/conn_pool.go b/lib/gat/gatling/conn_pool/conn_pool.go index d10508eca7f87575d349b40c5ee823339ae005cd..0c69a9df590c04ee6d706ce7d80e046a93f0ca42 100644 --- a/lib/gat/gatling/conn_pool/conn_pool.go +++ b/lib/gat/gatling/conn_pool/conn_pool.go @@ -226,6 +226,9 @@ func (c *ConnectionPool) GetServerInfo() []*protocol.ParameterStatus { } func (c *ConnectionPool) Query(client gat.Client, ctx context.Context, q string) (context.Context, error) { + // note: these deadlines aren't the time to complete the query, that should be controlled by postgres + // instead, this is the amount of time we allow the client to send extra data for a command + // (mainly so the server doesn't hang indefinitely waiting for client data) cmdCtx, done := context.WithDeadline(ctx, time.Now().Add(1*time.Second)) c.queries <- request[string]{