Fix specification caching mechanism

* The problem was that cache instance was instantiated on different
  Mistral instances and invalidation didn't work properly (known
  problem for local cache implementations). The solution, first of
  all, is to cache specifications by workflow execution ids so that
  we get a consistent spec value during workflow execution lifetime.
  And secondly, if we need to build a specification based on
  workflow definition id we also need to use 'updated_at' as part of
  cache key so that if workflow definition has changed the cache is
  updated properly. Old cache entities would be kicked out of cache
  by LRU algorithm as the cache runs out of space.

Change-Id: If97b2e47d8adcbd7b5d5844b56e24eac1b1ae6c1
This commit is contained in:
Renat Akhmerov
2016-08-09 18:56:50 +07:00
parent 297fe921e1
commit f2445acb28
12 changed files with 234 additions and 129 deletions

View File

@@ -43,7 +43,7 @@ def get_controller(wf_ex, wf_spec=None):
"""
if not wf_spec:
wf_spec = spec_parser.get_workflow_spec_by_id(wf_ex.workflow_id)
wf_spec = spec_parser.get_workflow_spec_by_execution_id(wf_ex.id)
wf_type = wf_spec.get_type()
@@ -81,7 +81,7 @@ class WorkflowController(object):
self.wf_ex = wf_ex
if wf_spec is None:
wf_spec = spec_parser.get_workflow_spec_by_id(wf_ex.workflow_id)
wf_spec = spec_parser.get_workflow_spec_by_execution_id(wf_ex.id)
self.wf_spec = wf_spec