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

Fix rare race condition with large datasets #139

Closed
sadsfae opened this issue Sep 1, 2017 · 3 comments
Closed

Fix rare race condition with large datasets #139

sadsfae opened this issue Sep 1, 2017 · 3 comments
Labels
Milestone

Comments

@sadsfae
Copy link
Member

sadsfae commented Sep 1, 2017

We've noticed a very rare race condition that can cause incorrect notifications to get sent out if the 7,5,3,1 day expirations are checked while we're making heavy use of /opt/quads/bin/quads-cli

This also may affect other notifications.

We will try implementing a timeout/retry to both urllib and requests library calls to work around this.

@sadsfae sadsfae added the bug label Sep 1, 2017
@sadsfae sadsfae added this to the 1.0 milestone Sep 1, 2017
@sadsfae
Copy link
Member Author

sadsfae commented Sep 6, 2017

The bug seems to show up with a large yaml dataset (240kb / 10k lines+).

Traceback (most recent call last):
  File "/tmp/quadsVoV7/quads/bin/quads-cli", line 455, in <module>
    main(sys.argv[1:])
  File "/tmp/quadsVoV7/quads/bin/quads-cli", line 445, in main
    js = r.json()
  File "/usr/lib/python2.7/site-packages/requests/models.py", line 866, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib64/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

@sadsfae
Copy link
Member Author

sadsfae commented Sep 6, 2017

and here is quads-daemon service side trace:

127.0.0.1 - - [06/Sep/2017 17:47:56] "POST /api/v1/query HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50454)
Traceback (most recent call last):
  File "/usr/lib64/python2.7/SocketServer.py", line 596, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib64/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib64/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/usr/lib64/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib64/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
    method()
  File "/tmp/quadsGKFi/quads/bin/quads-daemon", line 650, in do_POST
    cloud_summary = quads.query_cloud_summary(data['date'][0], True)
  File "/tmp/quadsGKFi/quads/lib/Quads.py", line 798, in query_cloud_summary
    summary = self.query_cloud_hosts(datearg)
  File "/tmp/quadsGKFi/quads/lib/Quads.py", line 759, in query_cloud_hosts
    default_cloud, current_cloud, current_override = self.find_current(h, datearg)
  File "/tmp/quadsGKFi/quads/lib/Quads.py", line 198, in find_current
    start_obj = datetime.datetime.strptime(hosts[host]["schedule"][override]["start"], '%Y-%m-%d %H:%M')
TypeError: 'NoneType' object has no attribute '__getitem__'
----------------------------------------

@sadsfae
Copy link
Member Author

sadsfae commented Sep 6, 2017

Update: it seems moving to urllib2.urlopen(url, timeout=1200) does help but we're still sometimes accessing data in memory that has not yet been written to disk. We need one more safeguard here in the fcntl library code to ensure we flush before things are queried.

@sadsfae sadsfae changed the title urllib and requests Python libraries need timeouts Fix rare race condition with large datasets Sep 6, 2017
@sadsfae sadsfae closed this as completed in 256f2d9 Sep 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant