Hey all, I've been doing some hacking on this lib and noticed this issue during development. Looks like it is closely related to #6, though I am not building new connections in a loop, I am simply attempting to gracefully shutdown the system in order to avoid error conditions as much as possible.
So, I noticed that even after I tear down any open streams that I've created in my program, and all other resources have shutdown, the tokio runtime will still not exit because it is waiting on a few resources. After doing some digging, I created a test case as follows:
Here are the JSON logs mentioned above in my test case. These are from /connz. Please note: the first three connections were there before starting my nitox program, and remain there even after I manually kill the program (aka, they are nats internal).
{
"server_id": "EYKg2swNQ9eHDUQ6PVhghE",
"now": "2019-01-21T00:46:24.3239911Z",
"num_connections": 6,
"total": 6,
"offset": 0,
"limit": 1024,
"connections": [
{
"cid": 1,
"ip": "127.0.0.1",
"port": 34318,
"start": "2019-01-18T06:04:45.691982154Z",
"last_activity": "2019-01-20T00:01:36.9471481Z",
"rtt": "275µs",
"uptime": "5h8m49s",
"idle": "2h7m0s",
"pending_bytes": 0,
"in_msgs": 347,
"out_msgs": 0,
"in_bytes": 15217,
"out_bytes": 0,
"subscriptions": 0,
"name": "_NSS-nats-streaming-cluster-send",
"lang": "go",
"version": "1.6.0"
},
{
"cid": 2,
"ip": "127.0.0.1",
"port": 34320,
"start": "2019-01-18T06:04:45.693148843Z",
"last_activity": "2019-01-21T00:41:14.3273053Z",
"rtt": "929µs",
"uptime": "5h8m49s",
"idle": "5m10s",
"pending_bytes": 0,
"in_msgs": 1615,
"out_msgs": 1206,
"in_bytes": 11107,
"out_bytes": 8712,
"subscriptions": 8,
"name": "_NSS-nats-streaming-cluster-general",
"lang": "go",
"version": "1.6.0"
},
{
"cid": 3,
"ip": "127.0.0.1",
"port": 34322,
"start": "2019-01-18T06:04:45.693702396Z",
"last_activity": "2019-01-20T00:01:36.9453977Z",
"rtt": "576µs",
"uptime": "5h8m49s",
"idle": "2h7m0s",
"pending_bytes": 0,
"in_msgs": 0,
"out_msgs": 15,
"in_bytes": 0,
"out_bytes": 375,
"subscriptions": 0,
"name": "_NSS-nats-streaming-cluster-acks",
"lang": "go",
"version": "1.6.0"
},
{
"cid": 67,
"ip": "172.20.0.1",
"port": 46212,
"start": "2019-01-21T00:45:35.573159Z",
"last_activity": "2019-01-21T00:45:35.5760492Z",
"rtt": "2ms",
"uptime": "48s",
"idle": "48s",
"pending_bytes": 0,
"in_msgs": 0,
"out_msgs": 0,
"in_bytes": 0,
"out_bytes": 0,
"subscriptions": 0,
"name": "nitox",
"lang": "rust",
"version": "0.1.x"
},
{
"cid": 68,
"ip": "172.20.0.1",
"port": 46210,
"start": "2019-01-21T00:45:35.573364Z",
"last_activity": "2019-01-21T00:45:35.5762686Z",
"rtt": "2ms",
"uptime": "48s",
"idle": "48s",
"pending_bytes": 0,
"in_msgs": 0,
"out_msgs": 0,
"in_bytes": 0,
"out_bytes": 0,
"subscriptions": 0,
"name": "nitox",
"lang": "rust",
"version": "0.1.x"
},
{
"cid": 69,
"ip": "172.20.0.1",
"port": 46214,
"start": "2019-01-21T00:45:35.5744776Z",
"last_activity": "2019-01-21T00:45:35.5761763Z",
"rtt": "1ms",
"uptime": "48s",
"idle": "48s",
"pending_bytes": 0,
"in_msgs": 0,
"out_msgs": 0,
"in_bytes": 0,
"out_bytes": 0,
"subscriptions": 0,
"name": "nitox",
"lang": "rust",
"version": "0.1.x"
}
]
}
Hey all, I've been doing some hacking on this lib and noticed this issue during development. Looks like it is closely related to #6, though I am not building new connections in a loop, I am simply attempting to gracefully shutdown the system in order to avoid error conditions as much as possible.
So, I noticed that even after I tear down any open streams that I've created in my program, and all other resources have shutdown, the tokio runtime will still not exit because it is waiting on a few resources. After doing some digging, I created a test case as follows:
NatsClient.drop(client)and then resolve the future./connzto check on the open connections, and I see that there will still be 3 open connections fromnats(I've added the JSON output below).My analysis:
Here are the JSON logs mentioned above in my test case. These are from
/connz. Please note: the first three connections were there before starting my nitox program, and remain there even after I manually kill the program (aka, they are nats internal).{ "server_id": "EYKg2swNQ9eHDUQ6PVhghE", "now": "2019-01-21T00:46:24.3239911Z", "num_connections": 6, "total": 6, "offset": 0, "limit": 1024, "connections": [ { "cid": 1, "ip": "127.0.0.1", "port": 34318, "start": "2019-01-18T06:04:45.691982154Z", "last_activity": "2019-01-20T00:01:36.9471481Z", "rtt": "275µs", "uptime": "5h8m49s", "idle": "2h7m0s", "pending_bytes": 0, "in_msgs": 347, "out_msgs": 0, "in_bytes": 15217, "out_bytes": 0, "subscriptions": 0, "name": "_NSS-nats-streaming-cluster-send", "lang": "go", "version": "1.6.0" }, { "cid": 2, "ip": "127.0.0.1", "port": 34320, "start": "2019-01-18T06:04:45.693148843Z", "last_activity": "2019-01-21T00:41:14.3273053Z", "rtt": "929µs", "uptime": "5h8m49s", "idle": "5m10s", "pending_bytes": 0, "in_msgs": 1615, "out_msgs": 1206, "in_bytes": 11107, "out_bytes": 8712, "subscriptions": 8, "name": "_NSS-nats-streaming-cluster-general", "lang": "go", "version": "1.6.0" }, { "cid": 3, "ip": "127.0.0.1", "port": 34322, "start": "2019-01-18T06:04:45.693702396Z", "last_activity": "2019-01-20T00:01:36.9453977Z", "rtt": "576µs", "uptime": "5h8m49s", "idle": "2h7m0s", "pending_bytes": 0, "in_msgs": 0, "out_msgs": 15, "in_bytes": 0, "out_bytes": 375, "subscriptions": 0, "name": "_NSS-nats-streaming-cluster-acks", "lang": "go", "version": "1.6.0" }, { "cid": 67, "ip": "172.20.0.1", "port": 46212, "start": "2019-01-21T00:45:35.573159Z", "last_activity": "2019-01-21T00:45:35.5760492Z", "rtt": "2ms", "uptime": "48s", "idle": "48s", "pending_bytes": 0, "in_msgs": 0, "out_msgs": 0, "in_bytes": 0, "out_bytes": 0, "subscriptions": 0, "name": "nitox", "lang": "rust", "version": "0.1.x" }, { "cid": 68, "ip": "172.20.0.1", "port": 46210, "start": "2019-01-21T00:45:35.573364Z", "last_activity": "2019-01-21T00:45:35.5762686Z", "rtt": "2ms", "uptime": "48s", "idle": "48s", "pending_bytes": 0, "in_msgs": 0, "out_msgs": 0, "in_bytes": 0, "out_bytes": 0, "subscriptions": 0, "name": "nitox", "lang": "rust", "version": "0.1.x" }, { "cid": 69, "ip": "172.20.0.1", "port": 46214, "start": "2019-01-21T00:45:35.5744776Z", "last_activity": "2019-01-21T00:45:35.5761763Z", "rtt": "1ms", "uptime": "48s", "idle": "48s", "pending_bytes": 0, "in_msgs": 0, "out_msgs": 0, "in_bytes": 0, "out_bytes": 0, "subscriptions": 0, "name": "nitox", "lang": "rust", "version": "0.1.x" } ] }