api7 / lua-resty-etcd

Nonblocking Lua etcd driver library for OpenResty

Home Page:https://api7.ai/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature: support `compact` for etcd v3

Yiyiyimu opened this issue · comments

The length of keyspace is not limited to 1000 anymore in v3. To avoid performance degradation and eventual storage space exhaustion, operation compact could drop all information about keys superseded prior to a given keyspace revision. And the compacted ones could not be accessed by get or watch. Normally, there would be auto compaction when etcd is running.
Detail could be found here.

Currently when I test to get the key at the compacted revision, the response would be successfully returned as

# +{
# +  body = {
# +    code = 11,
# +    error = "etcdserver: mvcc: required revision has been compacted",
# +    message = "etcdserver: mvcc: required revision has been compacted"
# +  },
# +  body_reader = <function 1>,
# +  has_body = true,
# +  headers = {
# +    ["Access-Control-Allow-Headers"] = "accept, content-type, authorization",
# +    ["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS, PUT, DELETE",
# +    ["Access-Control-Allow-Origin"] = "*",
# +    ["Content-Type"] = "application/json",
# +    Date = "Tue, 14 Jul 2020 02:34:11 GMT",
# +    Trailer = "Grpc-Trailer-Content-Type",
# +    ["Transfer-Encoding"] = "chunked",
# +    <metatable> = {
# +      __index = <function 2>,
# +      __newindex = <function 3>,
# +      normalised = {
# +        ["access-control-allow-headers"] = "Access-Control-Allow-Headers",
# +        ["access-control-allow-methods"] = "Access-Control-Allow-Methods",
# +        ["access-control-allow-origin"] = "Access-Control-Allow-Origin",
# +        ["content-type"] = "Content-Type",
# +        date = "Date",
# +        trailer = "Trailer",
# +        ["transfer-encoding"] = "Transfer-Encoding"
# +      }
# +    }
# +  },
# +  read_body = <function 4>,
# +  read_trailers = <function 5>,
# +  reason = "Bad Request",
# +  status = 400,
# +  trailer_reader = <function 6>

However, there would be error:

"2020/07/14 10:27:29 [error] 22853#0: *1 [lua] http.lua:951: request_uri(): unread data in buffer, client: 127.0.0.1, server: localhost, request: \"GET /t HTTP/1.1\", host: \"localhost\""

I'll submit a draft PR to reproduce the problem