Results of some YAQL/Jinja functions that hit DB can be cached per transaction

Bug #1864823 reported by Renat Akhmerov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mistral
Fix Released
Medium
Renat Akhmerov

Bug Description

A workflow can use lots of YAQL/Jinja functions like task(), execution() that hit database within one DB transaction. However, those calls to DB are not cached by the SQLAlchemy session since access is not done using primary key (id) but rather things like name or other filters. At the same time some of these functions can be safely cached per one TX if we know that possible changes in parallel transactions can be ignored. "task()" is one of such functions.

Changed in mistral:
milestone: none → ussuri-2
assignee: nobody → Renat Akhmerov (rakhmerov)
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on mistral (master)

Change abandoned by Eyal (<email address hidden>) on branch: master
Review: https://review.opendev.org/709693

Changed in mistral:
milestone: ussuri-2 → ussuri-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to mistral (master)

Reviewed: https://review.opendev.org/709693
Committed: https://git.openstack.org/cgit/openstack/mistral/commit/?id=756bd5566ac965f62626dd70dc3d09041248f40f
Submitter: Zuul
Branch: master

commit 756bd5566ac965f62626dd70dc3d09041248f40f
Author: Renat Akhmerov <email address hidden>
Date: Tue Feb 25 18:27:29 2020 +0700

    Add caching for YAQL/Jinja expression functions

    * Functions like task() can be safely cached per one DB
      transaction. It will decrease the number of DB hits.
      This patch adds @tx_cached decorator that caches
      any function result using a thread local cache having
      same scope as a DB transaction.
    * Style changes.

    Closes-Bug: #1864823
    Change-Id: Id00eae3cb8483dfe08f549ce7dd981b3c92df09a

Changed in mistral:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to mistral (master)

Fix proposed to branch: master
Review: https://review.opendev.org/711172

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to mistral (master)

Reviewed: https://review.opendev.org/711172
Committed: https://git.openstack.org/cgit/openstack/mistral/commit/?id=77b450d78553d131c70b8c94a269b250d39fc956
Submitter: Zuul
Branch: master

commit 77b450d78553d131c70b8c94a269b250d39fc956
Author: Renat Akhmerov <email address hidden>
Date: Wed Mar 4 14:28:49 2020 +0700

    Add a unit test for @tx_cached and fix a bug in it

    * Added a unit tests for the decorator @tx_cached. The tests
      helped find a bug in the implementation. One of the conditions
      in the decorator was wrong.

    Closes-Bug: #1864823
    Change-Id: I441310539f7949aea569d85ed998deea4fa0d0b0

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/mistral 10.0.0.0b3

This issue was fixed in the openstack/mistral 10.0.0.0b3 development milestone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.