frappe / insights

Open source analytics / business intelligence tool (BI)
https://frappe.io/insights
GNU Affero General Public License v3.0
390 stars 187 forks source link

Document modified error on dashboard #181

Closed nextchamp-saqib closed 9 months ago

nextchamp-saqib commented 10 months ago

if same stored query is used to make multiple dashboard chart, then refreshing the dashboard throws "document modified" error

Traceback:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 83, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 53, in handle
    return _RESTAPIHandler(call, doctype, name).get_response()
  File "apps/frappe/frappe/api.py", line 69, in get_response
    return self.handle_method()
  File "apps/frappe/frappe/api.py", line 79, in handle_method
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 48, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 86, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1646, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/handler.py", line 308, in run_doc_method
    response = doc.run_method(method, **args)
  File "apps/frappe/frappe/model/document.py", line 935, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1306, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1288, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 932, in fn
    return method_object(*args, **kwargs)
  File "apps/frappe/frappe/utils/typing_validations.py", line 30, in wrapper
    return func(*args, **kwargs)
  File "apps/insights/insights/insights/doctype/insights_dashboard/insights_dashboard.py", line 64, in fetch_chart_data
    return InsightsDashboard.run_query(
  File "apps/insights/insights/insights/doctype/insights_dashboard/insights_dashboard.py", line 82, in run_query
    return get_or_set_cache(key, get_result, expiry=query_result_expiry_in_seconds)
  File "apps/insights/insights/cache_utils.py", line 26, in get_or_set_cache
    value = func()
  File "apps/insights/insights/insights/doctype/insights_dashboard/insights_dashboard.py", line 72, in get_result
    return query.fetch_results(additional_filters=additional_filters)
  File "apps/insights/insights/insights/doctype/insights_query/insights_query.py", line 184, in fetch_results
    self.is_stored and store_query(self, self._results)
  File "apps/insights/insights/insights/doctype/insights_data_source/sources/query_store.py", line 105, in store_query
    query_store.store_query(query, results)
  File "apps/insights/insights/insights/doctype/insights_data_source/sources/query_store.py", line 91, in store_query
    create_insights_table(table, force=True)
  File "apps/insights/insights/insights/doctype/insights_data_source/sources/utils.py", line 88, in create_insights_table
    doc.save(ignore_permissions=True)
  File "apps/frappe/frappe/model/document.py", line 329, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 358, in _save
    self.check_if_latest()
  File "apps/frappe/frappe/model/document.py", line 788, in check_if_latest
    frappe.msgprint(
  File "apps/frappe/frappe/__init__.py", line 518, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 467, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.TimestampMismatchError: Error: Document has been modified after you have opened it (2023-10-25 14:11:31.413615, 2023-10-25 14:11:31.451685). Please refresh to get the latest document.
nextchamp-saqib commented 9 months ago

fixed with b18568c