Changes in update_and_save not always committed

Bug #1331872 reported by Steve McLellan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Zane Bitter

Bug Description

This needs looking into by someone with more sqlalchemy knowledge than me, but in db/sqlalchemy/models.py, in HeatBase:update_and_save, there are some situations where changes are not immediately committed (or possibly ever committed) despite the session.commit().

One such case seems to be (and this affects code after Zane's commits to save the template during a stack-update) during a stack-update that adds a SoftwareDeployment; calls are made to store the template, and the code executes, but the changes are not made visible in the database.

Adding session.merge(self) just before the call to commit (line 79 in db/sqlalchemy/models.py) causes the object to get saved correctly. It's worth noting in this circumstance that a new session is created (as opposed to reusing an existing session attached to the object).

I will submit a patch for this tomorrow; if there any pitfalls please let me know.

Revision history for this message
Zane Bitter (zaneb) wrote :

Thanks to great analysis by Steve, we were able to track down the problem to the fact that template updates are being stored without passing a context, which contains the shared DB session. If we use the shared DB session, no merging should be required. Working on a fix now.

Changed in heat:
assignee: nobody → Zane Bitter (zaneb)
status: New → Confirmed
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/101288

Changed in heat:
status: Confirmed → In Progress
Zane Bitter (zaneb)
Changed in heat:
milestone: none → juno-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/101288
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=3ff80e61285b763a9d625692f1d790b9a36dd380
Submitter: Jenkins
Branch: master

commit 3ff80e61285b763a9d625692f1d790b9a36dd380
Author: Zane Bitter <email address hidden>
Date: Fri Jun 27 16:22:45 2014 -0400

    Pass the context when updating raw_templates

    Without a context, the raw_template was being stored using a different DB
    session, with the result that changes did not end up in the database.

    Also, don't use the same raw_template DB entry for the backup stack, since
    that causes competing modifications to the DB that break rollback.

    Change-Id: I6c71c19acac0b87943f36c57c2300cf2b0478aa3
    Closes-Bug: #1331872
    Related-Bug: #1291905
    Related-Bug: #1206702
    Related-Bug: #1328342

Changed in heat:
status: In Progress → Fix Committed
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: juno-2 → 2014.2
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.