Skip to content

Commit

Permalink
Remove update lockmode from compute_node_get_by_host
Browse files Browse the repository at this point in the history
Fixes bug #948066

This commit removes the usage of an update cursor so postgres
doesn't raise the error below
SELECT FOR UPDATE/SHARE cannot be applied to the nullable side of
an outer join

Change-Id: Ia1ede22df38d5f6a24372e0ad8ec25151ad195c7
  • Loading branch information
derekhiggins committed Mar 10, 2012
1 parent 7322c59 commit 5e7fd25
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions nova/db/sqlalchemy/api.py
Expand Up @@ -518,22 +518,21 @@ def compute_node_update(context, compute_id, values, auto_adjust):
compute_ref.save(session=session)


# Note: these operations use with_lockmode() ... so this will only work
# reliably with engines that support row-level locking
# (postgres, mysql+innodb and above).

def compute_node_get_by_host(context, host):
"""Get all capacity entries for the given host."""
session = get_session()
with session.begin():
node = session.query(models.ComputeNode).\
options(joinedload('service')).\
filter(models.Service.host == host).\
filter_by(deleted=False).\
with_lockmode('update')
filter_by(deleted=False)
return node.first()


# Note: these operations use with_lockmode() ... so this will only work
# reliably with engines that support row-level locking
# (postgres, mysql+innodb and above).

def compute_node_capacity_find(context, minimum_ram_mb, minimum_disk_gb):
"""Get all enabled hosts with enough ram and disk."""
session = get_session()
Expand Down

0 comments on commit 5e7fd25

Please sign in to comment.