)]}'
{"nova/conductor/manager.py":[{"author":{"_account_id":1247,"name":"Mark McLoughlin","email":"markmc@redhat.com","username":"markmc"},"change_message_id":"b6da864611152ff799a381f2be26aa37edc07853","unresolved":false,"context_lines":[{"line_number":308,"context_line":"        result \u003d self.db.instance_fault_create(context, values)"},{"line_number":309,"context_line":"        return jsonutils.to_primitive(result)"},{"line_number":310,"context_line":""},{"line_number":311,"context_line":"    def vol_get_usage_by_time(self, context, start_time):"},{"line_number":312,"context_line":"        result \u003d self.db.vol_get_usage_by_time(context, start_time)"},{"line_number":313,"context_line":"        return jsonutils.to_primitive(result)"},{"line_number":314,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAAPH%2F%2FnUU%3D","line":311,"updated":"2013-05-29 10:26:42.000000000","message":"We should add a note that this method can be removed when we create version 2.0 of the conductor RPC API","commit_id":"3147c6e5db7f93756af632e6c9940d30b24f4b82"},{"author":{"_account_id":6969,"name":"Michael Kerrin","email":"michael.kerrin@hpe.com","username":"mkerrin"},"change_message_id":"5aef661240c08c80af8ccb1054dbb3ea89c5e1bd","unresolved":false,"context_lines":[{"line_number":308,"context_line":"        result \u003d self.db.instance_fault_create(context, values)"},{"line_number":309,"context_line":"        return jsonutils.to_primitive(result)"},{"line_number":310,"context_line":""},{"line_number":311,"context_line":"    def vol_get_usage_by_time(self, context, start_time):"},{"line_number":312,"context_line":"        result \u003d self.db.vol_get_usage_by_time(context, start_time)"},{"line_number":313,"context_line":"        return jsonutils.to_primitive(result)"},{"line_number":314,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAAPH%2F%2Fm%2FY%3D","line":311,"in_reply_to":"AAAAPH%2F%2FnUU%3D","updated":"2013-05-29 14:34:21.000000000","message":"Done.","commit_id":"3147c6e5db7f93756af632e6c9940d30b24f4b82"},{"author":{"_account_id":1247,"name":"Mark McLoughlin","email":"markmc@redhat.com","username":"markmc"},"change_message_id":"b6da864611152ff799a381f2be26aa37edc07853","unresolved":false,"context_lines":[{"line_number":316,"context_line":"                         wr_bytes, instance, last_refreshed\u003dNone,"},{"line_number":317,"context_line":"                         update_totals\u003dFalse):"},{"line_number":318,"context_line":"        # The session object is needed here, as the vol_usage object returned"},{"line_number":319,"context_line":"        # needs to bound to it in order to refresh its data"},{"line_number":320,"context_line":"        session \u003d db_session.get_session()"},{"line_number":321,"context_line":"        vol_usage \u003d self.db.vol_usage_update(context, vol_id,"},{"line_number":322,"context_line":"                                             rd_req, rd_bytes,"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAAPH%2F%2FnUc%3D","line":319,"updated":"2013-05-29 10:26:42.000000000","message":"That really doesn\u0027t make sense to me - could you elaborate? I\u0027m struggling to see how creating the session here makes any difference vs having vol_usage_update() create the session ... it\u0027s not like we\u0027re re-using the session","commit_id":"3147c6e5db7f93756af632e6c9940d30b24f4b82"},{"author":{"_account_id":1247,"name":"Mark McLoughlin","email":"markmc@redhat.com","username":"markmc"},"change_message_id":"4b3935ed1fd828ddfb4488e0498b152df7205c4e","unresolved":false,"context_lines":[{"line_number":316,"context_line":"                         wr_bytes, instance, last_refreshed\u003dNone,"},{"line_number":317,"context_line":"                         update_totals\u003dFalse):"},{"line_number":318,"context_line":"        # The session object is needed here, as the vol_usage object returned"},{"line_number":319,"context_line":"        # needs to bound to it in order to refresh its data"},{"line_number":320,"context_line":"        session \u003d db_session.get_session()"},{"line_number":321,"context_line":"        vol_usage \u003d self.db.vol_usage_update(context, vol_id,"},{"line_number":322,"context_line":"                                             rd_req, rd_bytes,"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAAPH%2F%2Fmiw%3D","line":319,"in_reply_to":"AAAAPH%2F%2Fmqk%3D","updated":"2013-05-29 15:03:36.000000000","message":"Uggh, that\u0027s pretty nasty - I guess vol_usage has a weak reference on the session. Pretty non-obvious, but if there\u0027s an obvious failure when you change this ... then ok","commit_id":"3147c6e5db7f93756af632e6c9940d30b24f4b82"},{"author":{"_account_id":6969,"name":"Michael Kerrin","email":"michael.kerrin@hpe.com","username":"mkerrin"},"change_message_id":"5aef661240c08c80af8ccb1054dbb3ea89c5e1bd","unresolved":false,"context_lines":[{"line_number":316,"context_line":"                         wr_bytes, instance, last_refreshed\u003dNone,"},{"line_number":317,"context_line":"                         update_totals\u003dFalse):"},{"line_number":318,"context_line":"        # The session object is needed here, as the vol_usage object returned"},{"line_number":319,"context_line":"        # needs to bound to it in order to refresh its data"},{"line_number":320,"context_line":"        session \u003d db_session.get_session()"},{"line_number":321,"context_line":"        vol_usage \u003d self.db.vol_usage_update(context, vol_id,"},{"line_number":322,"context_line":"                                             rd_req, rd_bytes,"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAAPH%2F%2Fmqk%3D","line":319,"in_reply_to":"AAAAPH%2F%2FnUc%3D","updated":"2013-05-29 14:34:21.000000000","message":"If we didn\u0027t create the session object here, the self.db.vol_usage_update method creates the session. Then when we try and send the volume usage notification (here, in this method) we need to perform a SQL query to retrieve the tot_reads column which may not have been loaded into the database. In this case we get the following exception:\n\n...\nFile \"/opt/stack/nova/nova/conductor/manager.py\", line 351, in vol_usage_update\n    compute_utils.usage_volume_info(vol_usage))\n  File \"/opt/stack/nova/nova/compute/utils.py\", line 303, in usage_volume_info\n    reads\u003dvol_usage[\u0027tot_reads\u0027] + vol_usage[\u0027curr_reads\u0027],\n  File \"/opt/stack/nova/nova/openstack/common/db/sqlalchemy/models.py\", line 57, in __getitem__\n    return getattr(self, key)\n  File \"/opt/stack/nova/.venv/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py\", line 168, in __get__\n    return self.impl.get(instance_state(instance),dict_)\n  File \"/opt/stack/nova/.venv/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py\", line 451, in get\n    value \u003d callable_(passive)\n  File \"/opt/stack/nova/.venv/local/lib/python2.7/site-packages/sqlalchemy/orm/state.py\", line 285, in __call__\n    self.manager.deferred_scalar_loader(self, toload)\n  File \"/opt/stack/nova/.venv/local/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py\", line 1673, in _load_scalar_attributes\n    (state_str(state)))\nDetachedInstanceError: Instance \u003cVolumeUsage at 0x766ba90\u003e is not bound to a Session; attribute refresh operation cannot proceed\n\nThis is because the self.db.vol_usage_update method has returned and the session is reclaimed by the gc.\n\nBy creating the session object here we get around this, and the instance can perform the SQL query if it needs to. The nova.tests.compute.test_compute.ComputeVolumeTestCase.test_detach_volume_usage test will exercise this. So if you pass in None for the session in the call to self.db.vol_usage_update you will see the above exception.\n\nHope that helps.","commit_id":"3147c6e5db7f93756af632e6c9940d30b24f4b82"}]}
