From cc819ad83bf7bba4f6b63925929e42e7a237fb99 Mon Sep 17 00:00:00 2001 From: "Chris S. Kim" Date: Fri, 25 Nov 2022 15:46:56 -0500 Subject: [PATCH] [OSS] Add boilerplate for proto files implementing BlockableQuery (#15554) --- .changelog/_3729.txt | 3 +++ internal/tools/proto-gen-rpc-glue/main.go | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 .changelog/_3729.txt diff --git a/.changelog/_3729.txt b/.changelog/_3729.txt new file mode 100644 index 0000000000..6032c69ed5 --- /dev/null +++ b/.changelog/_3729.txt @@ -0,0 +1,3 @@ +```release-note:bug +namespace: **(Enterprise Only)** Fix a bug that caused blocking queries during namespace replication to timeout +``` \ No newline at end of file diff --git a/internal/tools/proto-gen-rpc-glue/main.go b/internal/tools/proto-gen-rpc-glue/main.go index f66118cfc6..865fce973c 100644 --- a/internal/tools/proto-gen-rpc-glue/main.go +++ b/internal/tools/proto-gen-rpc-glue/main.go @@ -595,6 +595,16 @@ func (msg *%[1]s) AllowStaleRead() bool { return msg.%[2]s.AllowStaleRead() } +// BlockingTimeout implements pool.BlockableQuery +func (msg *%[1]s) BlockingTimeout(maxQueryTime, defaultQueryTime time.Duration) time.Duration { + maxTime := structs.DurationFromProto(msg.%[2]s.GetMaxQueryTime()) + o := structs.QueryOptions{ + MaxQueryTime: maxTime, + MinQueryIndex: msg.%[2]s.GetMinQueryIndex(), + } + return o.BlockingTimeout(maxQueryTime, defaultQueryTime) +} + // HasTimedOut implements structs.RPCInfo func (msg *%[1]s) HasTimedOut(start time.Time, rpcHoldTimeout time.Duration, a time.Duration, b time.Duration) (bool, error) { if msg == nil || msg.%[2]s == nil {