Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write with :: causes goroutine panic #320

Open
goodboy opened this issue May 15, 2020 · 0 comments
Open

Write with :: causes goroutine panic #320

goodboy opened this issue May 15, 2020 · 0 comments

Comments

@goodboy
Copy link
Contributor

goodboy commented May 15, 2020

Using the pymarketstore client you can crash the handling goroutine and subsequently cause the connection to drop:

import pymarketstore as pymkts 
param = pymkts.Params('BTC', '1Min', 'OHLCV', limit=10) 
cli = pymkts.Client(endpoint='http://localhost:5993/rpc')

Now write to the server using the :::

[ins] In [55]: cli.write(data, 'qt::tsla/1Min/Tick')                                            
---------------------------------------------------------------------------
RemoteDisconnected                        Traceback (most recent call last)
~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    664             # Make the request on the httplib connection object.
--> 665             httplib_response = self._make_request(
    666                 conn,

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    420                     # Otherwise it looks like a bug in the code.
--> 421                     six.raise_from(e, None)
    422         except (SocketTimeout, BaseSSLError, SocketError) as e:

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/urllib3/packages/six.py in raise_from(value, from_value)

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    415                 try:
--> 416                     httplib_response = conn.getresponse()
    417                 except BaseException as e:

/usr/lib/python3.8/http/client.py in getresponse(self)
   1321             try:
-> 1322                 response.begin()
   1323             except ConnectionError:

/usr/lib/python3.8/http/client.py in begin(self)
    302         while True:
--> 303             version, status, reason = self._read_status()
    304             if status != CONTINUE:

/usr/lib/python3.8/http/client.py in _read_status(self)
    271             # sending a valid response.
--> 272             raise RemoteDisconnected("Remote end closed connection without"
    273                                      " response")

RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

ProtocolError                             Traceback (most recent call last)
~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    438             if not chunked:
--> 439                 resp = conn.urlopen(
    440                     method=request.method,

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    718 
--> 719             retries = retries.increment(
    720                 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    399             if read is False or not self._is_method_retryable(method):
--> 400                 raise six.reraise(type(error), error, _stacktrace)
    401             elif read is not None:

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/urllib3/packages/six.py in reraise(tp, value, tb)
    733             if value.__traceback__ is not tb:
--> 734                 raise value.with_traceback(tb)
    735             raise value

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    664             # Make the request on the httplib connection object.
--> 665             httplib_response = self._make_request(
    666                 conn,

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    420                     # Otherwise it looks like a bug in the code.
--> 421                     six.raise_from(e, None)
    422         except (SocketTimeout, BaseSSLError, SocketError) as e:

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/urllib3/packages/six.py in raise_from(value, from_value)

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    415                 try:
--> 416                     httplib_response = conn.getresponse()
    417                 except BaseException as e:

/usr/lib/python3.8/http/client.py in getresponse(self)
   1321             try:
-> 1322                 response.begin()
   1323             except ConnectionError:

/usr/lib/python3.8/http/client.py in begin(self)
    302         while True:
--> 303             version, status, reason = self._read_status()
    304             if status != CONTINUE:

/usr/lib/python3.8/http/client.py in _read_status(self)
    271             # sending a valid response.
--> 272             raise RemoteDisconnected("Remote end closed connection without"
    273                                      " response")

ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/pymarketstore/client.py in write(self, recarray, tbk, isvariablelength)
    119         try:
--> 120             reply = self.rpc.call("DataService.Write", **writer)
    121         except requests.exceptions.ConnectionError:

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/pymarketstore/jsonrpc.py in call(self, method, **kwargs)
     26     def call(self, method, **kwargs):
---> 27         return getattr(self, method)(**kwargs)
     28 

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/pymarketstore/jsonrpc.py in call(**kwargs)
     19         def call(**kwargs):
---> 20             return self._session.post(
     21                 self._endpoint,

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/requests/sessions.py in post(self, url, data, json, **kwargs)
    580 
--> 581         return self.request('POST', url, data=data, json=json, **kwargs)
    582 

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    532         send_kwargs.update(settings)
--> 533         resp = self.send(prep, **send_kwargs)
    534 

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/requests/sessions.py in send(self, request, **kwargs)
    645         # Send the request
--> 646         r = adapter.send(request, **kwargs)
    647 

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    497         except (ProtocolError, socket.error) as err:
--> 498             raise ConnectionError(err, request=request)
    499 

ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
<ipython-input-55-8195a7601413> in <module>
----> 1 cli.write(data, 'qt::tsla/1Min/Tick')

~/.local/share/virtualenvs/piker-gtvBeoc2/lib/python3.8/site-packages/pymarketstore/client.py in write(self, recarray, tbk, isvariablelength)
    120             reply = self.rpc.call("DataService.Write", **writer)
    121         except requests.exceptions.ConnectionError:
--> 122             raise requests.exceptions.ConnectionError(
    123                 "Could not contact server")
    124         reply_obj = self.rpc.codec.loads(reply.content, encoding='utf-8')

ConnectionError: Could not contact server

docker container backtrace:

2020/05/15 22:58:21 http: panic serving 172.17.0.1:42442: runtime error: index out of range [1] with length 1
goroutine 15 [running]:
net/http.(*conn).serve.func1(0xc0002dae60)
	/usr/local/go/src/net/http/server.go:1772 +0x139
panic(0x11c51a0, 0xc00008eb40)
	/usr/local/go/src/runtime/panic.go:975 +0x3e3
github.com/alpacahq/marketstore/utils/io.(*TimeBucketKey).GetItemInCategory(0xc00025b568, 0x1264235, 0x9, 0xc000091e30, 0xc0012dfb58)
	/go/src/github.com/alpacahq/marketstore/utils/io/keytypes.go:77 +0x100
github.com/alpacahq/marketstore/utils/io.(*TimeBucketKey).GetTimeFrame(0xc00025b568, 0xc000091e30, 0xc00025b598, 0xc00025b4d8)
	/go/src/github.com/alpacahq/marketstore/utils/io/keytypes.go:124 +0x44
github.com/alpacahq/marketstore/executor.WriteCSM(0xc000091e30, 0xc000091e00, 0x0, 0x0)
	/go/src/github.com/alpacahq/marketstore/executor/writer.go:265 +0xf0
github.com/alpacahq/marketstore/frontend.(*DataService).Write(0x1b2a878, 0xc000168300, 0xc0012d8da0, 0xc0012d8ec0, 0x0, 0x0)
	/go/src/github.com/alpacahq/marketstore/frontend/write.go:43 +0xca
reflect.Value.call(0xc0012d2280, 0xc0012ca0e0, 0x13, 0x125fc44, 0x4, 0xc00025ba50, 0x4, 0x4, 0xc00025b930, 0x97017d, ...)
	/usr/local/go/src/reflect/value.go:460 +0x8ab
reflect.Value.Call(0xc0012d2280, 0xc0012ca0e0, 0x13, 0xc00025ba50, 0x4, 0x4, 0x0, 0x1, 0x203000)
	/usr/local/go/src/reflect/value.go:321 +0xb4
github.com/alpacahq/rpc/rpc2.(*Server).ServeHTTP(0xc0012c6030, 0x1379e40, 0xc0002d8620, 0xc000168300)
	/go/src/github.com/alpacahq/marketstore/vendor/github.com/alpacahq/rpc/rpc2/server.go:195 +0x49c
github.com/alpacahq/marketstore/frontend.(*RpcServer).ServeHTTP(0xc0012ca000, 0x1379e40, 0xc0002d8620, 0xc000168300)
	/go/src/github.com/alpacahq/marketstore/frontend/server.go:29 +0x143
net/http.(*ServeMux).ServeHTTP(0x1af1a60, 0x1379e40, 0xc0002d8620, 0xc000168300)
	/usr/local/go/src/net/http/server.go:2387 +0x1a5
net/http.serverHandler.ServeHTTP(0xc0002d81c0, 0x1379e40, 0xc0002d8620, 0xc000168300)
	/usr/local/go/src/net/http/server.go:2807 +0xa3
net/http.(*conn).serve(0xc0002dae60, 0x137b840, 0xc0012d0400)
	/usr/local/go/src/net/http/server.go:1895 +0x86c
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2933 +0x35c
2020/05/15 23:01:04 http: panic serving 172.17.0.1:42560: runtime error: index out of range [1] with length 1
goroutine 98 [running]:
net/http.(*conn).serve.func1(0xc0002dae60)
	/usr/local/go/src/net/http/server.go:1772 +0x139
panic(0x11c51a0, 0xc00008e240)
	/usr/local/go/src/runtime/panic.go:975 +0x3e3
github.com/alpacahq/marketstore/utils/io.(*TimeBucketKey).GetItemInCategory(0xc00015d568, 0x1264235, 0x9, 0xc000109c80, 0xc00010a638)
	/go/src/github.com/alpacahq/marketstore/utils/io/keytypes.go:77 +0x100
github.com/alpacahq/marketstore/utils/io.(*TimeBucketKey).GetTimeFrame(0xc00015d568, 0xc000109c80, 0xc00015d598, 0xc00015d4d8)
	/go/src/github.com/alpacahq/marketstore/utils/io/keytypes.go:124 +0x44
github.com/alpacahq/marketstore/executor.WriteCSM(0xc000109c80, 0xc000109c00, 0x0, 0x0)
	/go/src/github.com/alpacahq/marketstore/executor/writer.go:265 +0xf0
github.com/alpacahq/marketstore/frontend.(*DataService).Write(0x1b2a878, 0xc000168100, 0xc00026e080, 0xc00021f980, 0x0, 0x0)
	/go/src/github.com/alpacahq/marketstore/frontend/write.go:43 +0xca
reflect.Value.call(0xc0012d2280, 0xc0012ca0e0, 0x13, 0x125fc44, 0x4, 0xc00015da50, 0x4, 0x4, 0xc00015d930, 0x97017d, ...)
	/usr/local/go/src/reflect/value.go:460 +0x8ab
reflect.Value.Call(0xc0012d2280, 0xc0012ca0e0, 0x13, 0xc00015da50, 0x4, 0x4, 0x0, 0x1, 0x1)
	/usr/local/go/src/reflect/value.go:321 +0xb4
github.com/alpacahq/rpc/rpc2.(*Server).ServeHTTP(0xc0012c6030, 0x1379e40, 0xc0002d82a0, 0xc000168100)
	/go/src/github.com/alpacahq/marketstore/vendor/github.com/alpacahq/rpc/rpc2/server.go:195 +0x49c
github.com/alpacahq/marketstore/frontend.(*RpcServer).ServeHTTP(0xc0012ca000, 0x1379e40, 0xc0002d82a0, 0xc000168100)
	/go/src/github.com/alpacahq/marketstore/frontend/server.go:29 +0x143
net/http.(*ServeMux).ServeHTTP(0x1af1a60, 0x1379e40, 0xc0002d82a0, 0xc000168100)
	/usr/local/go/src/net/http/server.go:2387 +0x1a5
net/http.serverHandler.ServeHTTP(0xc0002d81c0, 0x1379e40, 0xc0002d82a0, 0xc000168100)
	/usr/local/go/src/net/http/server.go:2807 +0xa3
net/http.(*conn).serve(0xc0002dae60, 0x137b840, 0xc0012d0040)
	/usr/local/go/src/net/http/server.go:1895 +0x86c
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2933 +0x35c
2020/05/15 23:01:06 http: panic serving 172.17.0.1:42564: runtime error: index out of range [1] with length 1
goroutine 100 [running]:
net/http.(*conn).serve.func1(0xc0002daf00)
	/usr/local/go/src/net/http/server.go:1772 +0x139
panic(0x11c51a0, 0xc0012ce1a0)
	/usr/local/go/src/runtime/panic.go:975 +0x3e3
github.com/alpacahq/marketstore/utils/io.(*TimeBucketKey).GetItemInCategory(0xc0000d3568, 0x1264235, 0x9, 0xc000090780, 0xc0012fa498)
	/go/src/github.com/alpacahq/marketstore/utils/io/keytypes.go:77 +0x100
github.com/alpacahq/marketstore/utils/io.(*TimeBucketKey).GetTimeFrame(0xc0000d3568, 0xc000090780, 0xc0000d3598, 0xc0000d34d8)
	/go/src/github.com/alpacahq/marketstore/utils/io/keytypes.go:124 +0x44
github.com/alpacahq/marketstore/executor.WriteCSM(0xc000090780, 0xc000090700, 0x0, 0x0)
	/go/src/github.com/alpacahq/marketstore/executor/writer.go:265 +0xf0
github.com/alpacahq/marketstore/frontend.(*DataService).Write(0x1b2a878, 0xc0001c4200, 0xc0002c6320, 0xc0002c6780, 0x0, 0x0)
	/go/src/github.com/alpacahq/marketstore/frontend/write.go:43 +0xca
reflect.Value.call(0xc0012d2280, 0xc0012ca0e0, 0x13, 0x125fc44, 0x4, 0xc0000d3a50, 0x4, 0x4, 0xc0000d3930, 0x97017d, ...)
	/usr/local/go/src/reflect/value.go:460 +0x8ab
reflect.Value.Call(0xc0012d2280, 0xc0012ca0e0, 0x13, 0xc0000d3a50, 0x4, 0x4, 0x0, 0x1, 0x0)
	/usr/local/go/src/reflect/value.go:321 +0xb4
github.com/alpacahq/rpc/rpc2.(*Server).ServeHTTP(0xc0012c6030, 0x1379e40, 0xc000016000, 0xc0001c4200)
	/go/src/github.com/alpacahq/marketstore/vendor/github.com/alpacahq/rpc/rpc2/server.go:195 +0x49c
github.com/alpacahq/marketstore/frontend.(*RpcServer).ServeHTTP(0xc0012ca000, 0x1379e40, 0xc000016000, 0xc0001c4200)
	/go/src/github.com/alpacahq/marketstore/frontend/server.go:29 +0x143
net/http.(*ServeMux).ServeHTTP(0x1af1a60, 0x1379e40, 0xc000016000, 0xc0001c4200)
	/usr/local/go/src/net/http/server.go:2387 +0x1a5
net/http.serverHandler.ServeHTTP(0xc0002d81c0, 0x1379e40, 0xc000016000, 0xc0001c4200)
	/usr/local/go/src/net/http/server.go:2807 +0xa3
net/http.(*conn).serve(0xc0002daf00, 0x137b840, 0xc000092000)
	/usr/local/go/src/net/http/server.go:1895 +0x86c
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2933 +0x35c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant