From 9dc28000010830ce30d6c1fd022de85b7d306cd3 Mon Sep 17 00:00:00 2001 From: Thibault Deutsch Date: Tue, 21 Mar 2023 23:32:25 +0000 Subject: [PATCH] region/client: send request timeout to HBase TODO: - how to write a test for this? - what exception is returned? - are we guaranteed to get a reply if the request timeout? - what if the requests is dropped from the queue? --- region/client.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/region/client.go b/region/client.go index 4d81cd5b..8fbc76fb 100644 --- a/region/client.go +++ b/region/client.go @@ -626,6 +626,15 @@ func (c *client) send(rpc hrpc.Call) (uint32, error) { RequestParam: proto.Bool(true), } + deadline, ok := rpc.Context().Deadline() + if ok { + // Timeout shouldn't be negative, as we just tested the .Done() channel before entering this + // function. But if this happen, it's okay, the cast to uint32 will give us a big timeout + // value. + timeout := time.Until(deadline) + header.Timeout = proto.Uint32(uint32(timeout.Milliseconds())) + } + if s, ok := rpc.(canSerializeCellBlocks); ok && s.CellBlocksEnabled() { // request can be serialized to cellblocks request, cellblocks, cellblocksLen = s.SerializeCellBlocks()