tempodb / tempodb-python

Python client for TempoDB
MIT License
28 stars 19 forks source link

BR: Delete series does not handle very large lists #32

Closed platinummonkey closed 2 years ago

platinummonkey commented 10 years ago

Sending 5000 keys to delete with the delete_series method results in the following:

client.delete_series(keys=keys)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/cody/venv/local/lib/python2.7/site-packages/tempodb/client.py", line 61, in delete_series
    json = self.request('/series/', method='DELETE', params=params)
  File "/home/cody/venv/local/lib/python2.7/site-packages/tempodb/client.py", line 247, in request
    json = simplejson.loads(response.text)
  File "/home/cody/venv/local/lib/python2.7/site-packages/simplejson/__init__.py", line 488, in loads
    return _default_decoder.decode(s)
  File "/home/cody/venv/local/lib/python2.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/home/cody/venv/local/lib/python2.7/site-packages/simplejson/decoder.py", line 389, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Using the latest version in PyPi.

myagley commented 10 years ago

Hi Cody. Thanks for the bug report. Unfortunately this client does not report errors as well as it should. We are in the process of fixing that. The json error you are seeing is a red herring. I suspect that the true error is that the http request's url is too long.

We encode the information for which series to delete in the querystring of the url. 5000 series keys will create a url ~10kb (depending on the size of the keys). We can investigate updating the api to pass this information in the body. In the meantime, you have a couple of options for workarounds:

I realize that these options aren't ideal. I apologize for that. I'll queue up the change to allow the series key list in the body of the request.