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 sync issues #5615

Merged
merged 3 commits into from Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/installguide/release_notes.rst
Expand Up @@ -15,6 +15,8 @@ Bug fixes
^^^^^^^^^

* Fix rare ``GEOSException`` on systems with libgeos :url-issue:`5592`
* Sync'ing timeouts fixed :url-issue:`5615`
* Platform-specific ``*.pyc`` artifacts found in distributed installers, likely harmless :url-issue:`5611`

0.17.5
------
Expand Down
6 changes: 5 additions & 1 deletion kalite/packages/bundled/fle_utils/internet/decorators.py
Expand Up @@ -28,7 +28,11 @@ def api_handle_error_with_json_wrapper_fn(request, *args, **kwargs):
except Http404:
raise
except Exception as e:
logger.error("Error in JSON view: {}".format(request.path))
if hasattr(request, 'path'):
logger.error("Error in JSON view: {}".format(request.path))
else:
logger.error("Error in JSON view. Request also has no attribute 'path', so not sure how this got called.")
logger.error(request)
traceback.print_exc()
return JsonResponseMessageError(_("Unexpected error: %(err)s") % {"err": e}, status=500)
return api_handle_error_with_json_wrapper_fn
Expand Down
3 changes: 2 additions & 1 deletion kalite/packages/bundled/securesync/api_client.py
Expand Up @@ -20,8 +20,9 @@ def __init__(self, host=None, require_trusted=True, verbose=True):
self.url = settings.CENTRAL_SERVER_URL
else:
self.url = "%s://%s/" % (settings.SECURESYNC_PROTOCOL, settings.CENTRAL_SERVER_HOST)
self.parsed_url = urllib2.urlparse.urlparse(self.url)
else:
parsed_url = urllib2.urlparse.urlparse(host)
self.parsed_url = urllib2.urlparse.urlparse(host)
self.url = "%s://%s" % (self.parsed_url.scheme, self.parsed_url.netloc)

self.require_trusted = require_trusted
Expand Down
8 changes: 7 additions & 1 deletion kalite/packages/bundled/securesync/engine/api_client.py
Expand Up @@ -21,11 +21,14 @@ class SyncClient(BaseClient):
session = None

def post(self, path, payload={}, *args, **kwargs):
kwargs.setdefault("timeout", 120)
if self.session and self.session.client_nonce:
payload["client_nonce"] = self.session.client_nonce
return super(SyncClient, self).post(path, payload, *args, **kwargs)

def get(self, path, payload={}, *args, **kwargs):
# Set a high timeout since the server can be heavily loaded at times
kwargs.setdefault("timeout", 120)
if self.session and self.session.client_nonce:
payload["client_nonce"] = self.session.client_nonce
# add a random parameter to ensure the request is not cached
Expand Down Expand Up @@ -145,7 +148,10 @@ def close_session(self):

def get_server_device_counters(self):
r = self.get("device/counters")
data = json.loads(r.content or "{}")
try:
data = json.loads(r.content or "{}")
except ValueError:
raise Exception("Did not receive proper JSON data from server. URL: {}\n\nActual data:\n\n{}".format(r.url, r.content))
if "error" in data:
raise Exception("Server error in retrieving counters: " + data["error"])
return data.get("device_counters", {})
Expand Down
2 changes: 1 addition & 1 deletion kalite/packages/bundled/securesync/engine/utils.py
Expand Up @@ -64,7 +64,7 @@ def get_device_counters(**kwargs):

# The local device may have items that haven't incremented the device counter,
# but instead have deferred until sync time. Include those!
if device.is_own_device():
if not getattr(settings, 'CENTRAL_SERVER', False) and device.is_own_device():
cnt = 0
for Model in _syncing_models:
cnt += Model.all_objects.filter(Q(counter__isnull=True) | Q(signature__isnull=True)).count() # include deleted records
Expand Down
8 changes: 4 additions & 4 deletions kalite/settings/base.py
Expand Up @@ -106,8 +106,8 @@
'level': 'INFO',
},
'django.request': {
'handlers': ['null'],
'level': 'DEBUG',
'handlers': ['console', 'file'],
'level': logging.ERROR,
'propagate': False,
},
'kalite': {
Expand All @@ -132,7 +132,7 @@
},
'cherrypy.access': {
'handlers': ['console', 'file'],
'level': LOGGING_LEVEL,
'level': logging.ERROR,
'propagate': False,
},
'cherrypy.error': {
Expand All @@ -142,7 +142,7 @@
},
'': {
'handlers': ['console', 'file'],
'level': 'INFO',
'level': logging.INFO,
'propagate': False,
},
}
Expand Down