)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"45c59bc30bdd5d68c2c7907d2ef437c19847fb34","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"delete_subnet instead of using SELECT FOR UPDATE deletes"},{"line_number":10,"context_line":"the IPAllocations that can be auto-deleted straight away."},{"line_number":11,"context_line":"An Exception is raised if there are ports that cannot be"},{"line_number":12,"context_line":"autodeleted."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"delete_network tries to delete all ports and subnets before"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"1abeadc6_927b20f4","line":11,"updated":"2014-08-29 11:07:54.000000000","message":"Exception -\u003e exception \n\n(since are talking about a generic one as opposed to Exception specifically)","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"8ec97ea9a14c62cd60cd4317ac9c854f10a0579d","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"delete_subnet instead of using SELECT FOR UPDATE deletes"},{"line_number":10,"context_line":"the IPAllocations that can be auto-deleted straight away."},{"line_number":11,"context_line":"An Exception is raised if there are ports that cannot be"},{"line_number":12,"context_line":"autodeleted."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"delete_network tries to delete all ports and subnets before"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"fa98f980_91481a5d","line":11,"in_reply_to":"1abeadc6_927b20f4","updated":"2014-09-01 10:51:12.000000000","message":"Done","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"45c59bc30bdd5d68c2c7907d2ef437c19847fb34","unresolved":false,"context_lines":[{"line_number":12,"context_line":"autodeleted."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"delete_network tries to delete all ports and subnets before"},{"line_number":15,"context_line":"performing the network deletion. No lock is needed here,"},{"line_number":16,"context_line":"if some other process modifies the Port or Subnet table,"},{"line_number":17,"context_line":"adding new items,the network deletion will fail because"},{"line_number":18,"context_line":"of a violation of a foreign key contraint."}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"1abeadc6_f28454d4","line":15,"updated":"2014-08-29 11:07:54.000000000","message":"here, -\u003e here -","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"8ec97ea9a14c62cd60cd4317ac9c854f10a0579d","unresolved":false,"context_lines":[{"line_number":12,"context_line":"autodeleted."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"delete_network tries to delete all ports and subnets before"},{"line_number":15,"context_line":"performing the network deletion. No lock is needed here,"},{"line_number":16,"context_line":"if some other process modifies the Port or Subnet table,"},{"line_number":17,"context_line":"adding new items,the network deletion will fail because"},{"line_number":18,"context_line":"of a violation of a foreign key contraint."}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"fa98f980_31684eba","line":15,"in_reply_to":"1abeadc6_f28454d4","updated":"2014-09-01 10:51:12.000000000","message":"Done","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"45c59bc30bdd5d68c2c7907d2ef437c19847fb34","unresolved":false,"context_lines":[{"line_number":14,"context_line":"delete_network tries to delete all ports and subnets before"},{"line_number":15,"context_line":"performing the network deletion. No lock is needed here,"},{"line_number":16,"context_line":"if some other process modifies the Port or Subnet table,"},{"line_number":17,"context_line":"adding new items,the network deletion will fail because"},{"line_number":18,"context_line":"of a violation of a foreign key contraint."},{"line_number":19,"context_line":"In that case the operation will be retried."},{"line_number":20,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"1abeadc6_326a4c1a","line":17,"updated":"2014-08-29 11:07:54.000000000","message":",the -\u003e , the","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"8ec97ea9a14c62cd60cd4317ac9c854f10a0579d","unresolved":false,"context_lines":[{"line_number":14,"context_line":"delete_network tries to delete all ports and subnets before"},{"line_number":15,"context_line":"performing the network deletion. No lock is needed here,"},{"line_number":16,"context_line":"if some other process modifies the Port or Subnet table,"},{"line_number":17,"context_line":"adding new items,the network deletion will fail because"},{"line_number":18,"context_line":"of a violation of a foreign key contraint."},{"line_number":19,"context_line":"In that case the operation will be retried."},{"line_number":20,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"fa98f980_5165d2df","line":17,"in_reply_to":"1abeadc6_326a4c1a","updated":"2014-09-01 10:51:12.000000000","message":"Done","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":7962,"name":"Ronak Shah","email":"ronak.malav.shah@gmail.com","username":"ronak"},"change_message_id":"f5ea7b3cd4b340957cde31efc897ec7cbe7ed3dc","unresolved":false,"context_lines":[{"line_number":16,"context_line":"if some other process modifies the Port or Subnet table,"},{"line_number":17,"context_line":"adding new items, the network deletion will fail because"},{"line_number":18,"context_line":"of a violation of a foreign key contraint."},{"line_number":19,"context_line":"In that case the operation will be retried."},{"line_number":20,"context_line":""},{"line_number":21,"context_line":"Change-Id: Ib4e9441a95d6c80b92a43d55fdeb18d7b51a1cf3"},{"line_number":22,"context_line":"Closes-bug: #1332917"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa98f980_cae5fc09","line":19,"updated":"2014-09-03 23:38:46.000000000","message":"Could you please add reference to ML2 plugin in the text above since this change is only for ML2?","commit_id":"59a9c04d3252ba556e731a4a0faff56d0a94e5d1"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"4a8f67792701257a791566c73c096085acf33b7d","unresolved":false,"context_lines":[{"line_number":16,"context_line":"if some other process modifies the Port or Subnet table,"},{"line_number":17,"context_line":"adding new items, the network deletion will fail because"},{"line_number":18,"context_line":"of a violation of a foreign key contraint."},{"line_number":19,"context_line":"In that case the operation will be retried."},{"line_number":20,"context_line":""},{"line_number":21,"context_line":"Change-Id: Ib4e9441a95d6c80b92a43d55fdeb18d7b51a1cf3"},{"line_number":22,"context_line":"Closes-bug: #1332917"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa98f980_76cda130","line":19,"in_reply_to":"fa98f980_cae5fc09","updated":"2014-09-05 14:43:25.000000000","message":"OK","commit_id":"59a9c04d3252ba556e731a4a0faff56d0a94e5d1"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"6522843fbd0ce4185555abbb2ef030adc6b68ce8","unresolved":false,"context_lines":[{"line_number":3,"context_line":"AuthorDate: 2014-08-19 19:41:16 +0200"},{"line_number":4,"context_line":"Commit:     rossella \u003crsblendido@suse.com\u003e"},{"line_number":5,"context_line":"CommitDate: 2014-09-15 16:54:11 +0200"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"Remove locking from network and subnet delete op"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"delete_subnet in Ml2 plugin instead of using SELECT FOR"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":8,"id":"fa98f980_c4a4d0a7","line":6,"updated":"2014-09-15 19:42:39.000000000","message":"Rossella, how are you verifying the correctness of this patch? Can you point me to Tempest tests that explicitly target concurrent network and subnet deletions? Do you have a testing strategy for this patch and similar ones?","commit_id":"0aae65a70f3e92eca0fcd7d822a2924c2c8f29ff"},{"author":{"_account_id":8873,"name":"Assaf Muller","email":"amuller@redhat.com","username":"amuller"},"change_message_id":"a9a1aebc0ddc8bff62c290d15c4a3f47446fe8f7","unresolved":false,"context_lines":[{"line_number":3,"context_line":"AuthorDate: 2014-08-19 19:41:16 +0200"},{"line_number":4,"context_line":"Commit:     rossella \u003crsblendido@suse.com\u003e"},{"line_number":5,"context_line":"CommitDate: 2014-09-15 16:54:11 +0200"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"Remove locking from network and subnet delete op"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"delete_subnet in Ml2 plugin instead of using SELECT FOR"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":8,"id":"baa201ad_45d7a5ed","line":6,"in_reply_to":"baa201ad_8f67ee24","updated":"2014-10-01 14:41:10.000000000","message":"Thanks for the reference!","commit_id":"0aae65a70f3e92eca0fcd7d822a2924c2c8f29ff"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"c899d1a60bb63c8944a860933ae494d1600ad49d","unresolved":false,"context_lines":[{"line_number":3,"context_line":"AuthorDate: 2014-08-19 19:41:16 +0200"},{"line_number":4,"context_line":"Commit:     rossella \u003crsblendido@suse.com\u003e"},{"line_number":5,"context_line":"CommitDate: 2014-09-15 16:54:11 +0200"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"Remove locking from network and subnet delete op"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"delete_subnet in Ml2 plugin instead of using SELECT FOR"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":8,"id":"baa201ad_8f67ee24","line":6,"in_reply_to":"fa98f980_c4a4d0a7","updated":"2014-10-01 13:54:24.000000000","message":"Assaf, in Tempest network and subnet deletion are tested and for the full job for example the tests run in parallel, so the operation can be considered concurrent. Apart from that I am writing a functional test see https://review.openstack.org/#/c/124136/","commit_id":"0aae65a70f3e92eca0fcd7d822a2924c2c8f29ff"}],"neutron/plugins/ml2/plugin.py":[{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"45c59bc30bdd5d68c2c7907d2ef437c19847fb34","unresolved":false,"context_lines":[{"line_number":604,"context_line":"        session \u003d context.session"},{"line_number":605,"context_line":"        while True:"},{"line_number":606,"context_line":"            try:"},{"line_number":607,"context_line":"                # No need of locking the Port of the Subnet table here."},{"line_number":608,"context_line":"                # If these tables are modified by another process, the"},{"line_number":609,"context_line":"                # deletion of the network from the DB will fail because of"},{"line_number":610,"context_line":"                # a foreign key constraint violation. The DBException will"}],"source_content_type":"text/x-python","patch_set":2,"id":"1abeadc6_37515e62","line":607,"updated":"2014-08-29 11:07:54.000000000","message":"of locking -\u003e to lock","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"8ec97ea9a14c62cd60cd4317ac9c854f10a0579d","unresolved":false,"context_lines":[{"line_number":604,"context_line":"        session \u003d context.session"},{"line_number":605,"context_line":"        while True:"},{"line_number":606,"context_line":"            try:"},{"line_number":607,"context_line":"                # No need of locking the Port of the Subnet table here."},{"line_number":608,"context_line":"                # If these tables are modified by another process, the"},{"line_number":609,"context_line":"                # deletion of the network from the DB will fail because of"},{"line_number":610,"context_line":"                # a foreign key constraint violation. The DBException will"}],"source_content_type":"text/x-python","patch_set":2,"id":"fa98f980_31069121","line":607,"in_reply_to":"1abeadc6_37515e62","updated":"2014-09-01 10:51:12.000000000","message":"Done","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"669caa3fcd89211251b2740a5d25095f492f53c1","unresolved":false,"context_lines":[{"line_number":619,"context_line":"                    only_auto_del \u003d all(p.device_owner"},{"line_number":620,"context_line":"                                        in db_base_plugin_v2."},{"line_number":621,"context_line":"                                        AUTO_DELETE_PORT_OWNERS"},{"line_number":622,"context_line":"                                        for p in ports)"},{"line_number":623,"context_line":"                    if not only_auto_del:"},{"line_number":624,"context_line":"                        LOG.debug(_(\"Tenant-owned ports exist\"))"},{"line_number":625,"context_line":"                        raise exc.NetworkInUse(net_id\u003did)"}],"source_content_type":"text/x-python","patch_set":2,"id":"1abeadc6_d1076c80","line":622,"updated":"2014-08-21 23:30:13.000000000","message":"With a network without ports, if a tenant port is created after the query in L615-617 and before the sql delete in L643, then the network and newly created port are wrongly deleted?","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"6d5fe463fb5bb7a08826f776fb6c0f032565456b","unresolved":false,"context_lines":[{"line_number":619,"context_line":"                    only_auto_del \u003d all(p.device_owner"},{"line_number":620,"context_line":"                                        in db_base_plugin_v2."},{"line_number":621,"context_line":"                                        AUTO_DELETE_PORT_OWNERS"},{"line_number":622,"context_line":"                                        for p in ports)"},{"line_number":623,"context_line":"                    if not only_auto_del:"},{"line_number":624,"context_line":"                        LOG.debug(_(\"Tenant-owned ports exist\"))"},{"line_number":625,"context_line":"                        raise exc.NetworkInUse(net_id\u003did)"}],"source_content_type":"text/x-python","patch_set":2,"id":"1abeadc6_e3701542","line":622,"in_reply_to":"1abeadc6_d1076c80","updated":"2014-08-22 08:04:48.000000000","message":"They won\u0027t be deleted, L643 will raise an exception because there\u0027s a foreign key constraint violation. Port has network id as foreign key.","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"669caa3fcd89211251b2740a5d25095f492f53c1","unresolved":false,"context_lines":[{"line_number":627,"context_line":"                    # Get subnets to auto-delete."},{"line_number":628,"context_line":"                    subnets \u003d (session.query(models_v2.Subnet)."},{"line_number":629,"context_line":"                               enable_eagerloads(False)."},{"line_number":630,"context_line":"                               filter_by(network_id\u003did).all())"},{"line_number":631,"context_line":"                    LOG.debug(_(\"Subnets to auto-delete: %s\"), subnets)"},{"line_number":632,"context_line":""},{"line_number":633,"context_line":"                    if not (ports or subnets):"}],"source_content_type":"text/x-python","patch_set":2,"id":"1abeadc6_5170bc0a","line":630,"updated":"2014-08-21 23:30:13.000000000","message":"What if a subnet is created after query?","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"6d5fe463fb5bb7a08826f776fb6c0f032565456b","unresolved":false,"context_lines":[{"line_number":627,"context_line":"                    # Get subnets to auto-delete."},{"line_number":628,"context_line":"                    subnets \u003d (session.query(models_v2.Subnet)."},{"line_number":629,"context_line":"                               enable_eagerloads(False)."},{"line_number":630,"context_line":"                               filter_by(network_id\u003did).all())"},{"line_number":631,"context_line":"                    LOG.debug(_(\"Subnets to auto-delete: %s\"), subnets)"},{"line_number":632,"context_line":""},{"line_number":633,"context_line":"                    if not (ports or subnets):"}],"source_content_type":"text/x-python","patch_set":2,"id":"1abeadc6_a3a1bd95","line":630,"in_reply_to":"1abeadc6_5170bc0a","updated":"2014-08-22 08:04:48.000000000","message":"Same as for Port. Subnet has network id as foreign key so the network deletion will fail","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"45c59bc30bdd5d68c2c7907d2ef437c19847fb34","unresolved":false,"context_lines":[{"line_number":731,"context_line":"                allocated \u003d (session.query(models_v2.IPAllocation)."},{"line_number":732,"context_line":"                             filter_by(subnet_id\u003did)."},{"line_number":733,"context_line":"                             join(models_v2.Port)."},{"line_number":734,"context_line":"                             filter_by(network_id\u003dsubnet[\u0027network_id\u0027])."},{"line_number":735,"context_line":"                             filter_by("},{"line_number":736,"context_line":"                                 device_owner\u003dconst.DEVICE_OWNER_DHCP)."},{"line_number":737,"context_line":"                             all())"}],"source_content_type":"text/x-python","patch_set":2,"id":"1abeadc6_724204ac","line":734,"updated":"2014-08-29 11:07:54.000000000","message":"This filter_by clause would seem to be unnecessary given that the set of ports associated with a given network id are a strict superset of the set of ports associated with a subnet id.  Please remove (and also on line 746).","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"8ec97ea9a14c62cd60cd4317ac9c854f10a0579d","unresolved":false,"context_lines":[{"line_number":731,"context_line":"                allocated \u003d (session.query(models_v2.IPAllocation)."},{"line_number":732,"context_line":"                             filter_by(subnet_id\u003did)."},{"line_number":733,"context_line":"                             join(models_v2.Port)."},{"line_number":734,"context_line":"                             filter_by(network_id\u003dsubnet[\u0027network_id\u0027])."},{"line_number":735,"context_line":"                             filter_by("},{"line_number":736,"context_line":"                                 device_owner\u003dconst.DEVICE_OWNER_DHCP)."},{"line_number":737,"context_line":"                             all())"}],"source_content_type":"text/x-python","patch_set":2,"id":"fa98f980_6c74be9c","line":734,"in_reply_to":"1abeadc6_724204ac","updated":"2014-09-01 10:51:12.000000000","message":"Done","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"45c59bc30bdd5d68c2c7907d2ef437c19847fb34","unresolved":false,"context_lines":[{"line_number":733,"context_line":"                             join(models_v2.Port)."},{"line_number":734,"context_line":"                             filter_by(network_id\u003dsubnet[\u0027network_id\u0027])."},{"line_number":735,"context_line":"                             filter_by("},{"line_number":736,"context_line":"                                 device_owner\u003dconst.DEVICE_OWNER_DHCP)."},{"line_number":737,"context_line":"                             all())"},{"line_number":738,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":739,"context_line":"                if allocated:"}],"source_content_type":"text/x-python","patch_set":2,"id":"1abeadc6_9207a0c9","line":736,"updated":"2014-08-29 11:07:54.000000000","message":"Would it be preferable to use an \u0027in\u0027 clause on db_base_plugin_v2.AUTO_DELETE_PORT_OWNERS to ensure that future additions to that list are picked up automatically by this method?","commit_id":"3451ec44308af25eaaea0598a16181944a765346"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"fa2b8dd1300531556009e8b8b1271eb3a90ef4cb","unresolved":false,"context_lines":[{"line_number":628,"context_line":"                        msg \u003d _(\"A concurrent port creation has occurred\")"},{"line_number":629,"context_line":"                        LOG.warning(msg)"},{"line_number":630,"context_line":"                        continue"},{"line_number":631,"context_line":""},{"line_number":632,"context_line":"            for port in ports:"},{"line_number":633,"context_line":"                try:"},{"line_number":634,"context_line":"                    self.delete_port(context, port.id)"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa98f980_316dae33","side":"PARENT","line":631,"updated":"2014-09-01 11:06:09.000000000","message":"Unrelated formatting change - please revert.","commit_id":"2b3c20591d295e874460d8f448dd2a7e199dc90f"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"966ea5fb7938c5806ed909857baa3b1ebdd66243","unresolved":false,"context_lines":[{"line_number":628,"context_line":"                        msg \u003d _(\"A concurrent port creation has occurred\")"},{"line_number":629,"context_line":"                        LOG.warning(msg)"},{"line_number":630,"context_line":"                        continue"},{"line_number":631,"context_line":""},{"line_number":632,"context_line":"            for port in ports:"},{"line_number":633,"context_line":"                try:"},{"line_number":634,"context_line":"                    self.delete_port(context, port.id)"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa98f980_e9a5f204","side":"PARENT","line":631,"in_reply_to":"fa98f980_316dae33","updated":"2014-09-01 14:35:09.000000000","message":"Done","commit_id":"2b3c20591d295e874460d8f448dd2a7e199dc90f"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"fa2b8dd1300531556009e8b8b1271eb3a90ef4cb","unresolved":false,"context_lines":[{"line_number":636,"context_line":"                    with excutils.save_and_reraise_exception():"},{"line_number":637,"context_line":"                        LOG.exception(_(\"Exception auto-deleting port %s\"),"},{"line_number":638,"context_line":"                                      port.id)"},{"line_number":639,"context_line":""},{"line_number":640,"context_line":"            for subnet in subnets:"},{"line_number":641,"context_line":"                try:"},{"line_number":642,"context_line":"                    self.delete_subnet(context, subnet.id)"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa98f980_516a321b","side":"PARENT","line":639,"updated":"2014-09-01 11:06:09.000000000","message":"Unrelated formatting change - please revert.","commit_id":"2b3c20591d295e874460d8f448dd2a7e199dc90f"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"966ea5fb7938c5806ed909857baa3b1ebdd66243","unresolved":false,"context_lines":[{"line_number":636,"context_line":"                    with excutils.save_and_reraise_exception():"},{"line_number":637,"context_line":"                        LOG.exception(_(\"Exception auto-deleting port %s\"),"},{"line_number":638,"context_line":"                                      port.id)"},{"line_number":639,"context_line":""},{"line_number":640,"context_line":"            for subnet in subnets:"},{"line_number":641,"context_line":"                try:"},{"line_number":642,"context_line":"                    self.delete_subnet(context, subnet.id)"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa98f980_09ab16d9","side":"PARENT","line":639,"in_reply_to":"fa98f980_516a321b","updated":"2014-09-01 14:35:09.000000000","message":"Done","commit_id":"2b3c20591d295e874460d8f448dd2a7e199dc90f"},{"author":{"_account_id":8213,"name":"Claudiu Belu","email":"cbelu@cloudbasesolutions.com","username":"claudiub"},"change_message_id":"4f76c9b7d16738a52d6fe06c7629ce5db6a1d603","unresolved":false,"context_lines":[{"line_number":704,"context_line":"                                 models_v2.Port.device_owner."},{"line_number":705,"context_line":"                                 in_(db_base_plugin_v2.AUTO_DELETE_PORT_OWNER)"},{"line_number":706,"context_line":"                             )."},{"line_number":707,"context_line":"                             all())"},{"line_number":708,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":709,"context_line":"                if allocated:"},{"line_number":710,"context_line":"                    map(session.delete, allocated)"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa98f980_623cc230","line":707,"updated":"2014-09-01 13:00:44.000000000","message":"I think this should be written on the line above. (L706).","commit_id":"80a901bd1488894712ad87d329f039ba7682e29b"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"966ea5fb7938c5806ed909857baa3b1ebdd66243","unresolved":false,"context_lines":[{"line_number":704,"context_line":"                                 models_v2.Port.device_owner."},{"line_number":705,"context_line":"                                 in_(db_base_plugin_v2.AUTO_DELETE_PORT_OWNER)"},{"line_number":706,"context_line":"                             )."},{"line_number":707,"context_line":"                             all())"},{"line_number":708,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":709,"context_line":"                if allocated:"},{"line_number":710,"context_line":"                    map(session.delete, allocated)"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa98f980_a9820a50","line":707,"in_reply_to":"fa98f980_623cc230","updated":"2014-09-01 14:35:09.000000000","message":"OK","commit_id":"80a901bd1488894712ad87d329f039ba7682e29b"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"dc7924d192e767f32022810c89cf021a15d32055","unresolved":false,"context_lines":[{"line_number":704,"context_line":"                             join(models_v2.Port)."},{"line_number":705,"context_line":"                             filter("},{"line_number":706,"context_line":"                                 models_v2.Port.device_owner."},{"line_number":707,"context_line":"                                 in_(db_base_plugin_v2.AUTO_DELETE_PORT_OWNERS)"},{"line_number":708,"context_line":"                             ).all())"},{"line_number":709,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":710,"context_line":"                if allocated:"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa98f980_892c66ad","line":707,"updated":"2014-09-01 14:48:46.000000000","message":"Good catch.","commit_id":"5f1741f9043dc58a1918efa0b6dc8a26bb4356ec"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"2013771c85aa6216187e8f07e1fb152bf377f1b0","unresolved":false,"context_lines":[{"line_number":714,"context_line":"                tenant_ports \u003d (session.query(models_v2.IPAllocation)."},{"line_number":715,"context_line":"                                filter_by(subnet_id\u003did)."},{"line_number":716,"context_line":"                                join(models_v2.Port)."},{"line_number":717,"context_line":"                                all())"},{"line_number":718,"context_line":"                if tenant_ports:"},{"line_number":719,"context_line":"                    LOG.debug(\"Tenant-owned ports exist\")"},{"line_number":720,"context_line":"                    raise exc.SubnetInUse(subnet_id\u003did)"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa98f980_d7640724","line":717,"updated":"2014-09-02 15:21:58.000000000","message":"In order to improve performance, instead of querying all tenant ports, you can query only one of them:\n\n tenant_port \u003dquery.first()\n if tenant_port:\n\nor only counts tenant_ports (the best is to count with a limit \u003d\u003d 1):\n\n  tenant_port_number \u003d query.count() # or query.limit(1).count() iirc","commit_id":"5f1741f9043dc58a1918efa0b6dc8a26bb4356ec"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"95bb2cc4d91749f1037badf355bdb3945c801ef4","unresolved":false,"context_lines":[{"line_number":714,"context_line":"                tenant_ports \u003d (session.query(models_v2.IPAllocation)."},{"line_number":715,"context_line":"                                filter_by(subnet_id\u003did)."},{"line_number":716,"context_line":"                                join(models_v2.Port)."},{"line_number":717,"context_line":"                                all())"},{"line_number":718,"context_line":"                if tenant_ports:"},{"line_number":719,"context_line":"                    LOG.debug(\"Tenant-owned ports exist\")"},{"line_number":720,"context_line":"                    raise exc.SubnetInUse(subnet_id\u003did)"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa98f980_d9e09998","line":717,"in_reply_to":"fa98f980_d7640724","updated":"2014-09-03 10:41:26.000000000","message":"Nice suggestion, thanks!","commit_id":"5f1741f9043dc58a1918efa0b6dc8a26bb4356ec"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"19b5a3db88e415bce8ef5afbd2ab1ed30520fca6","unresolved":false,"context_lines":[{"line_number":733,"context_line":""},{"line_number":734,"context_line":"                    LOG.debug(_(\"Committing transaction\"))"},{"line_number":735,"context_line":"                    break"},{"line_number":736,"context_line":""},{"line_number":737,"context_line":"            for a in allocated:"},{"line_number":738,"context_line":"                if a.port_id:"},{"line_number":739,"context_line":"                    # calling update_port() for each allocation to remove the"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa98f980_0954c41f","line":736,"updated":"2014-09-02 08:50:54.000000000","message":"previous the loop was executed for all network ports ... now it\u0027s only executed for network tenant ports","commit_id":"5f1741f9043dc58a1918efa0b6dc8a26bb4356ec"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"8b22d8d2ece67faf00cb0746c4391d2330150b3d","unresolved":false,"context_lines":[{"line_number":733,"context_line":""},{"line_number":734,"context_line":"                    LOG.debug(_(\"Committing transaction\"))"},{"line_number":735,"context_line":"                    break"},{"line_number":736,"context_line":""},{"line_number":737,"context_line":"            for a in allocated:"},{"line_number":738,"context_line":"                if a.port_id:"},{"line_number":739,"context_line":"                    # calling update_port() for each allocation to remove the"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa98f980_fcf2d26d","line":736,"in_reply_to":"fa98f980_0954c41f","updated":"2014-09-02 14:56:56.000000000","message":"Cedric I am not sure I am understanding what you mean here.\nThe loop was executed only for ports that can be auto-deleted, that is whose owner is in AUTO_DELETE_PORT_OWNERS . Tenant ports shouldn\u0027t be handled, see line 720 in my patch and line 725 in Base.\nThis hasn\u0027t changed.\nI would say that the loop is executed only for non tenant-owned ports.\nAm I missing something?","commit_id":"5f1741f9043dc58a1918efa0b6dc8a26bb4356ec"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"2013771c85aa6216187e8f07e1fb152bf377f1b0","unresolved":false,"context_lines":[{"line_number":733,"context_line":""},{"line_number":734,"context_line":"                    LOG.debug(_(\"Committing transaction\"))"},{"line_number":735,"context_line":"                    break"},{"line_number":736,"context_line":""},{"line_number":737,"context_line":"            for a in allocated:"},{"line_number":738,"context_line":"                if a.port_id:"},{"line_number":739,"context_line":"                    # calling update_port() for each allocation to remove the"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa98f980_773b5b38","line":736,"in_reply_to":"fa98f980_fcf2d26d","updated":"2014-09-02 15:21:58.000000000","message":"oups, my mistake","commit_id":"5f1741f9043dc58a1918efa0b6dc8a26bb4356ec"},{"author":{"_account_id":6854,"name":"YAMAMOTO Takashi","email":"yamamoto@midokura.com","username":"yamamoto"},"change_message_id":"f97a53dc34616419bf007500c98546b218bd929b","unresolved":false,"context_lines":[{"line_number":574,"context_line":"                # No need to lock the Port of the Subnet table here."},{"line_number":575,"context_line":"                # If these tables are modified by another process, the"},{"line_number":576,"context_line":"                # deletion of the network from the DB will fail because of"},{"line_number":577,"context_line":"                # a foreign key constraint violation. The DBException will"},{"line_number":578,"context_line":"                # be caught and the loop retried."},{"line_number":579,"context_line":"                with session.begin(subtransactions\u003dTrue):"},{"line_number":580,"context_line":"                    self._process_l3_delete(context, id)"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa98f980_cffc2b75","line":577,"range":{"start_line":577,"start_character":58,"end_line":577,"end_character":69},"updated":"2014-09-04 01:27:55.000000000","message":"s/DBException/DBError exception/","commit_id":"59a9c04d3252ba556e731a4a0faff56d0a94e5d1"},{"author":{"_account_id":7962,"name":"Ronak Shah","email":"ronak.malav.shah@gmail.com","username":"ronak"},"change_message_id":"f5ea7b3cd4b340957cde31efc897ec7cbe7ed3dc","unresolved":false,"context_lines":[{"line_number":617,"context_line":"            except os_db_exception.DBError as e:"},{"line_number":618,"context_line":"                with excutils.save_and_reraise_exception() as ctxt:"},{"line_number":619,"context_line":"                    if isinstance(e.inner_exception, sql_exc.IntegrityError):"},{"line_number":620,"context_line":"                        ctxt.reraise \u003d False"},{"line_number":621,"context_line":"                        msg \u003d _(\"A concurrent port creation has occurred\")"},{"line_number":622,"context_line":"                        LOG.warning(msg)"},{"line_number":623,"context_line":"                        continue"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa98f980_4a0caced","line":620,"updated":"2014-09-03 23:38:46.000000000","message":"Nit: Does it make sense to add port/subnet here? As either could cause db exception.","commit_id":"59a9c04d3252ba556e731a4a0faff56d0a94e5d1"},{"author":{"_account_id":7962,"name":"Ronak Shah","email":"ronak.malav.shah@gmail.com","username":"ronak"},"change_message_id":"f5ea7b3cd4b340957cde31efc897ec7cbe7ed3dc","unresolved":false,"context_lines":[{"line_number":728,"context_line":"                        mech_context)"},{"line_number":729,"context_line":""},{"line_number":730,"context_line":"                    LOG.debug(_(\"Deleting subnet record\"))"},{"line_number":731,"context_line":"                    record \u003d self._get_subnet(context, id)"},{"line_number":732,"context_line":"                    session.delete(record)"},{"line_number":733,"context_line":""},{"line_number":734,"context_line":"                    LOG.debug(_(\"Committing transaction\"))"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa98f980_2a2da8fe","line":731,"updated":"2014-09-03 23:38:46.000000000","message":"We are making two calls to subnet table here. \nFirst one is at 700 and second here. I think it can be avoided easily. \nCan you please look into that?","commit_id":"59a9c04d3252ba556e731a4a0faff56d0a94e5d1"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"4a8f67792701257a791566c73c096085acf33b7d","unresolved":false,"context_lines":[{"line_number":728,"context_line":"                        mech_context)"},{"line_number":729,"context_line":""},{"line_number":730,"context_line":"                    LOG.debug(_(\"Deleting subnet record\"))"},{"line_number":731,"context_line":"                    record \u003d self._get_subnet(context, id)"},{"line_number":732,"context_line":"                    session.delete(record)"},{"line_number":733,"context_line":""},{"line_number":734,"context_line":"                    LOG.debug(_(\"Committing transaction\"))"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa98f980_5117c744","line":731,"in_reply_to":"fa98f980_2a2da8fe","updated":"2014-09-05 14:43:25.000000000","message":"I filed a low-hanging-fruit bug for this https://bugs.launchpad.net/neutron/+bug/1366056","commit_id":"59a9c04d3252ba556e731a4a0faff56d0a94e5d1"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"d646ef4574aed0d544b914ac69eeb55399eea35b","unresolved":false,"context_lines":[{"line_number":575,"context_line":"                # If these tables are modified by another process, the"},{"line_number":576,"context_line":"                # deletion of the network from the DB will fail because of"},{"line_number":577,"context_line":"                # a foreign key constraint violation. The DBException will"},{"line_number":578,"context_line":"                # be caught and the loop retried."},{"line_number":579,"context_line":"                with session.begin(subtransactions\u003dTrue):"},{"line_number":580,"context_line":"                    self._process_l3_delete(context, id)"},{"line_number":581,"context_line":"                    # Get ports to auto-delete."}],"source_content_type":"text/x-python","patch_set":6,"id":"fa98f980_81b8e4e6","line":578,"updated":"2014-09-07 03:50:19.000000000","message":"I don\u0027t think such a long inline comment is necessary. Comments describing what the code will do should be avoided because they can cause a lot of confusion if the behavior changes later and the comment isn\u0027t update.\n\n# Locking isn\u0027t necessary. Foreign-key constraints prevent\n# deletion if concurrent creation happens.","commit_id":"477e08a28994157850b998decb7ab06c7259e20e"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"332ba5bc1bd50b33ff4bdefed9fb05be989ccc1b","unresolved":false,"context_lines":[{"line_number":575,"context_line":"                # If these tables are modified by another process, the"},{"line_number":576,"context_line":"                # deletion of the network from the DB will fail because of"},{"line_number":577,"context_line":"                # a foreign key constraint violation. The DBException will"},{"line_number":578,"context_line":"                # be caught and the loop retried."},{"line_number":579,"context_line":"                with session.begin(subtransactions\u003dTrue):"},{"line_number":580,"context_line":"                    self._process_l3_delete(context, id)"},{"line_number":581,"context_line":"                    # Get ports to auto-delete."}],"source_content_type":"text/x-python","patch_set":6,"id":"fa98f980_88bd4705","line":578,"in_reply_to":"fa98f980_81b8e4e6","updated":"2014-09-08 15:54:28.000000000","message":"Done","commit_id":"477e08a28994157850b998decb7ab06c7259e20e"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"29bbf7057d4e1135f43f86e7b2cacf70618d838d","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":8,"id":"da9df570_4404437e","updated":"2014-09-21 08:50:55.000000000","message":"The db-access semaphore should not be removed here until *all* of the with_lockmode(\u0027update\u0027) calls that affect the ports table are removed.\n\nThe tricky thing about the lockutils lock is that it wasn\u0027t here just because this method locks the ports table. It\u0027s also here because other methods lock the ports table (e.g. L323) and this one tries to access it. By removing the semaphore (which would yield on acquisition attempt if it\u0027s not available), we risk _commit_port_binding yielding while holding the table lock and then a coroutine running this code and deadlocking when it tries to delete the ports... :-(","commit_id":"0aae65a70f3e92eca0fcd7d822a2924c2c8f29ff"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"36cc8ab490ebc600655a5acfaf22ceeff811bef4","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":8,"id":"baa201ad_43a4f6b8","in_reply_to":"baa201ad_ef25dac2","updated":"2014-10-13 16:11:20.000000000","message":"Good catch Kevin.","commit_id":"0aae65a70f3e92eca0fcd7d822a2924c2c8f29ff"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"c899d1a60bb63c8944a860933ae494d1600ad49d","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":8,"id":"baa201ad_ef25dac2","in_reply_to":"da9df570_4404437e","updated":"2014-10-01 13:54:24.000000000","message":"You are totally right Kevin. My intent at the beginning was to remove completely all the with_lockmode(\u0027update\u0027) but since that\u0027s not done I am going to reset the semaphore. Thanks","commit_id":"0aae65a70f3e92eca0fcd7d822a2924c2c8f29ff"},{"author":{"_account_id":261,"name":"Salvatore Orlando","email":"salv.orlando@gmail.com","username":"salvatore-orlando"},"change_message_id":"6c0617b738ab60f7b1b5bc13b4b537503403acab","unresolved":false,"context_lines":[{"line_number":718,"context_line":"                             filter("},{"line_number":719,"context_line":"                                 models_v2.Port.device_owner."},{"line_number":720,"context_line":"                                 in_(db_base_plugin_v2.AUTO_DELETE_PORT_OWNERS)"},{"line_number":721,"context_line":"                             ).all())"},{"line_number":722,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":723,"context_line":"                if allocated:"},{"line_number":724,"context_line":"                    map(session.delete, allocated)"}],"source_content_type":"text/x-python","patch_set":9,"id":"9aa7fdbe_b6f009ca","line":721,"updated":"2014-10-27 12:22:05.000000000","message":"do we need to invoke the all() operation here?\nEven if this was the way the code worked before this patch, it seems that this has no benefits and is just extra cost.","commit_id":"bd95499bc0b913706030f2dac6da880433a0cf00"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"f9421c1741b3085fc72cc26d22f89b78adf74f94","unresolved":false,"context_lines":[{"line_number":718,"context_line":"                             filter("},{"line_number":719,"context_line":"                                 models_v2.Port.device_owner."},{"line_number":720,"context_line":"                                 in_(db_base_plugin_v2.AUTO_DELETE_PORT_OWNERS)"},{"line_number":721,"context_line":"                             ).all())"},{"line_number":722,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":723,"context_line":"                if allocated:"},{"line_number":724,"context_line":"                    map(session.delete, allocated)"}],"source_content_type":"text/x-python","patch_set":9,"id":"5a890539_b04a3b25","line":721,"in_reply_to":"5a890539_8e863c64","updated":"2014-11-20 18:56:57.000000000","message":"Sorry Salvatore for answering so late. I think we need it otherwise we cannot delete every allocation on line 724. Am I missing something?","commit_id":"bd95499bc0b913706030f2dac6da880433a0cf00"},{"author":{"_account_id":261,"name":"Salvatore Orlando","email":"salv.orlando@gmail.com","username":"salvatore-orlando"},"change_message_id":"a841115a40bb6324a88c1df276d1d844074dc37b","unresolved":false,"context_lines":[{"line_number":718,"context_line":"                             filter("},{"line_number":719,"context_line":"                                 models_v2.Port.device_owner."},{"line_number":720,"context_line":"                                 in_(db_base_plugin_v2.AUTO_DELETE_PORT_OWNERS)"},{"line_number":721,"context_line":"                             ).all())"},{"line_number":722,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":723,"context_line":"                if allocated:"},{"line_number":724,"context_line":"                    map(session.delete, allocated)"}],"source_content_type":"text/x-python","patch_set":9,"id":"5a890539_44283486","line":721,"in_reply_to":"9aa7fdbe_b6f009ca","updated":"2014-11-14 14:28:45.000000000","message":"do you think we should address this?","commit_id":"bd95499bc0b913706030f2dac6da880433a0cf00"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"a9f1fddaf9e84c595181bab4bef58daeabebf08e","unresolved":false,"context_lines":[{"line_number":718,"context_line":"                             filter("},{"line_number":719,"context_line":"                                 models_v2.Port.device_owner."},{"line_number":720,"context_line":"                                 in_(db_base_plugin_v2.AUTO_DELETE_PORT_OWNERS)"},{"line_number":721,"context_line":"                             ).all())"},{"line_number":722,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":723,"context_line":"                if allocated:"},{"line_number":724,"context_line":"                    map(session.delete, allocated)"}],"source_content_type":"text/x-python","patch_set":9,"id":"5a890539_8e863c64","line":721,"in_reply_to":"9aa7fdbe_b6f009ca","updated":"2014-11-19 11:07:54.000000000","message":"i think it might be the case where it\u0027s better to fetch all data at once.","commit_id":"bd95499bc0b913706030f2dac6da880433a0cf00"},{"author":{"_account_id":261,"name":"Salvatore Orlando","email":"salv.orlando@gmail.com","username":"salvatore-orlando"},"change_message_id":"6c0617b738ab60f7b1b5bc13b4b537503403acab","unresolved":false,"context_lines":[{"line_number":721,"context_line":"                             ).all())"},{"line_number":722,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":723,"context_line":"                if allocated:"},{"line_number":724,"context_line":"                    map(session.delete, allocated)"},{"line_number":725,"context_line":"                LOG.debug(\"Ports to auto-deallocate: %s\", allocated)"},{"line_number":726,"context_line":"                # Check if there are tenant owned ports"},{"line_number":727,"context_line":"                tenant_port \u003d (session.query(models_v2.IPAllocation)."}],"source_content_type":"text/x-python","patch_set":9,"id":"9aa7fdbe_368339cd","line":724,"updated":"2014-10-27 12:22:05.000000000","message":"I understand what you\u0027re doing here. I think it\u0027s a smart thing to do.\nAnd for this reason I\u0027ve chosen you to become the recipient of today\u0027s \"pedantry prize\"!\n\nThe routine works in this way:\n1) Find allocation for ports in AUTO_DELETE_PORT_OWNERS\n2) Delete them - one by one\n3) Find all allocations for the subnet\n4) Find if any allocation is found, because that would be a non autodeletable port\n\nIf we feel that #2 is necessary, can we remove all the ports in one step? It should be easy to do that\n\nThere is a slight chance than an allocation for an AUTO_DELETE_PORT_OWNER port is created between #1 and #3. According to the DB isolation level, query #3 might or might not see it. I seem to recall that mysql\u0027s default level is REPEATABLE_READ and therefore this won\u0027t happen, but I reckon this could happen with postgresql\n\nWhat if we just query for non AUTO_DELETE_PORT_OWNERS - this can be achieved specifiying in query #1 that the port for the allocation object must no be in AUTO_DELETE_PORT_OWNERS. Would that simplify things?","commit_id":"bd95499bc0b913706030f2dac6da880433a0cf00"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"1a1ea2fb6e747b2e4e59c5cf6bd9056485dae7d2","unresolved":false,"context_lines":[{"line_number":721,"context_line":"                             ).all())"},{"line_number":722,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":723,"context_line":"                if allocated:"},{"line_number":724,"context_line":"                    map(session.delete, allocated)"},{"line_number":725,"context_line":"                LOG.debug(\"Ports to auto-deallocate: %s\", allocated)"},{"line_number":726,"context_line":"                # Check if there are tenant owned ports"},{"line_number":727,"context_line":"                tenant_port \u003d (session.query(models_v2.IPAllocation)."}],"source_content_type":"text/x-python","patch_set":9,"id":"9aa7fdbe_9611f85f","line":724,"in_reply_to":"9aa7fdbe_368339cd","updated":"2014-10-29 16:43:20.000000000","message":"\u003eIf we feel that #2 is necessary, can we remove all the ports in one step? It \u003eshould be easy to do that\n\nRight now the query uses a join of 2 tables and Sqlalchemy AFAIK doesn\u0027t support delete on join. If I want to use device owner in the filter I need to join the Port and the IPAllocation table, can\u0027t think of any other solution. \n\n\u003eThere is a slight chance than an allocation for an AUTO_DELETE_PORT_OWNER \u003e port is created between #1 and #3. According to the DB isolation level, query \u003e #3 might or might not see it. \n\nIt\u0027s a very good point and you are totally right. To avoid that a new transaction can be started just before the read.\n\n\u003eWhat if we just query for non AUTO_DELETE_PORT_OWNERS - this can be \u003eachieved specifiying in query #1 that the port for the allocation object must no \u003ebe in AUTO_DELETE_PORT_OWNERS. Would that simplify things?\n\nLet\u0027s see if I got your suggestion:\nquery #1 : check if there are ports whose device owner is not in AUTO_DELETE_PORT_OWNERS\nif yes, raise, otherwise go on\nquery #2: delete all port whose device owner is in AUTO_DELETE_PORT_OWNERS\nquery #3: check if there\u0027s an allocation left, if there is, it must be a tenant port that was created between #1 and #2 so raise\n\nIs that what you meant?","commit_id":"bd95499bc0b913706030f2dac6da880433a0cf00"},{"author":{"_account_id":261,"name":"Salvatore Orlando","email":"salv.orlando@gmail.com","username":"salvatore-orlando"},"change_message_id":"a841115a40bb6324a88c1df276d1d844074dc37b","unresolved":false,"context_lines":[{"line_number":721,"context_line":"                             ).all())"},{"line_number":722,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":723,"context_line":"                if allocated:"},{"line_number":724,"context_line":"                    map(session.delete, allocated)"},{"line_number":725,"context_line":"                LOG.debug(\"Ports to auto-deallocate: %s\", allocated)"},{"line_number":726,"context_line":"                # Check if there are tenant owned ports"},{"line_number":727,"context_line":"                tenant_port \u003d (session.query(models_v2.IPAllocation)."}],"source_content_type":"text/x-python","patch_set":9,"id":"5a890539_447674a5","line":724,"in_reply_to":"9aa7fdbe_9611f85f","updated":"2014-11-14 14:28:45.000000000","message":"If you need 3 steps then it\u0027s not worth it. You are correct that during deletion there is still a chance some new port gets created, and you need to rollback everything.\n\nSo let\u0027s just forget about it. The current solution you\u0027ve found is better.","commit_id":"bd95499bc0b913706030f2dac6da880433a0cf00"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"48945c4891204fe37a005c874de75768680ee3de","unresolved":false,"context_lines":[{"line_number":727,"context_line":"                tenant_port \u003d (session.query(models_v2.IPAllocation)."},{"line_number":728,"context_line":"                               filter_by(subnet_id\u003did)."},{"line_number":729,"context_line":"                               join(models_v2.Port)."},{"line_number":730,"context_line":"                               first())"},{"line_number":731,"context_line":"                if tenant_port:"},{"line_number":732,"context_line":"                    LOG.debug(\"Tenant-owned ports exist\")"},{"line_number":733,"context_line":"                    raise exc.SubnetInUse(subnet_id\u003did)"}],"source_content_type":"text/x-python","patch_set":9,"id":"9aa7fdbe_6cb2574d","line":730,"updated":"2014-10-27 10:05:22.000000000","message":".count() should be more efficient as it avoids to deserialize a db object","commit_id":"bd95499bc0b913706030f2dac6da880433a0cf00"},{"author":{"_account_id":261,"name":"Salvatore Orlando","email":"salv.orlando@gmail.com","username":"salvatore-orlando"},"change_message_id":"a841115a40bb6324a88c1df276d1d844074dc37b","unresolved":false,"context_lines":[{"line_number":727,"context_line":"                tenant_port \u003d (session.query(models_v2.IPAllocation)."},{"line_number":728,"context_line":"                               filter_by(subnet_id\u003did)."},{"line_number":729,"context_line":"                               join(models_v2.Port)."},{"line_number":730,"context_line":"                               first())"},{"line_number":731,"context_line":"                if tenant_port:"},{"line_number":732,"context_line":"                    LOG.debug(\"Tenant-owned ports exist\")"},{"line_number":733,"context_line":"                    raise exc.SubnetInUse(subnet_id\u003did)"}],"source_content_type":"text/x-python","patch_set":9,"id":"5a890539_44ebd412","line":730,"in_reply_to":"9aa7fdbe_6cb2574d","updated":"2014-11-14 14:28:45.000000000","message":"I think the answer to this question is \"it depends\". There are surely cases where count is faster. and there are case where first() is faster.\n\nOne thing that makes me to lean towards first() is that its execution time is quite predictable, while the execution time for count() varies with the number of items in the IPAllocation table.","commit_id":"bd95499bc0b913706030f2dac6da880433a0cf00"},{"author":{"_account_id":6659,"name":"Paul Michali","email":"pc@michali.net","username":"pcm"},"change_message_id":"8e728a16bd79119f262942f2a80e62bf6622920f","unresolved":false,"context_lines":[{"line_number":30,"context_line":"from neutron.api.rpc.handlers import securitygroups_rpc"},{"line_number":31,"context_line":"from neutron.api.v2 import attributes"},{"line_number":32,"context_line":"from neutron.common import constants as const"},{"line_number":33,"context_line":"from neutron.common import exceptions as exc"},{"line_number":34,"context_line":"from neutron.common import ipv6_utils"},{"line_number":35,"context_line":"from neutron.common import rpc as n_rpc"},{"line_number":36,"context_line":"from neutron.common import topics"}],"source_content_type":"text/x-python","patch_set":10,"id":"5a890539_cfab8287","line":33,"updated":"2014-11-21 15:01:47.000000000","message":"Looks like PEP8 caught that this is no longer used.","commit_id":"46fef429bd5cfb15768e8f6e3f1230c6aabf55b9"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"80508a8bd20bd8ba7dedd9b26e1398f1612600f7","unresolved":false,"context_lines":[{"line_number":728,"context_line":"                    qry_allocated \u003d ("},{"line_number":729,"context_line":"                        qry_allocated.filter(models_v2.Port.device_owner."},{"line_number":730,"context_line":"                        in_(db_base_plugin_v2.AUTO_DELETE_PORT_OWNERS)))"},{"line_number":731,"context_line":"                allocated \u003d qry_allocated.all()"},{"line_number":732,"context_line":"                # Delete all the IPAllocation that can be auto-deleted"},{"line_number":733,"context_line":"                if allocated:"},{"line_number":734,"context_line":"                    map(session.delete, allocated)"}],"source_content_type":"text/x-python","patch_set":12,"id":"5a890539_5f28bf96","line":731,"updated":"2014-11-25 20:49:18.000000000","message":"allocated \u003d\u003d\u003eallocateds would be clearer","commit_id":"8169c4c3fc5a1a7f12c597d4bb1075e5892735ab"},{"author":{"_account_id":6524,"name":"Henry Gessau","email":"HenryG@gessau.net","username":"gessau"},"change_message_id":"40ac107daba6620e39ee58b7c8e42b4071a272ab","unresolved":false,"context_lines":[{"line_number":588,"context_line":"                # deletion of a floating IP with certain L3 backends."},{"line_number":589,"context_line":"                self._process_l3_delete(context, id)"},{"line_number":590,"context_line":"                # Locking isn\u0027t necessary. Foreign-key constraints prevent"},{"line_number":591,"context_line":"                # deletion if concurrent creation happens."},{"line_number":592,"context_line":"                with contextlib.nested(lockutils.lock(\u0027db-access\u0027),"},{"line_number":593,"context_line":"                                       session.begin(subtransactions\u003dTrue)):"},{"line_number":594,"context_line":"                    # Get ports to auto-delete."}],"source_content_type":"text/x-python","patch_set":13,"id":"5a890539_e3cbc4a1","line":591,"updated":"2014-12-03 15:38:39.000000000","message":"Nit: The comment says \"Locking isn\u0027t necessary\" and then the next line uses a lock. :) Perhaps be more specific:\n\n  # Using query().with_lockmode isn\u0027t necessary. ...","commit_id":"417d883251be3c0263492816e8ff6760a5754d18"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"f8afee02b02ff6cc1aa9d75dba0e2e5ff2c04a11","unresolved":false,"context_lines":[{"line_number":588,"context_line":"                # deletion of a floating IP with certain L3 backends."},{"line_number":589,"context_line":"                self._process_l3_delete(context, id)"},{"line_number":590,"context_line":"                # Locking isn\u0027t necessary. Foreign-key constraints prevent"},{"line_number":591,"context_line":"                # deletion if concurrent creation happens."},{"line_number":592,"context_line":"                with contextlib.nested(lockutils.lock(\u0027db-access\u0027),"},{"line_number":593,"context_line":"                                       session.begin(subtransactions\u003dTrue)):"},{"line_number":594,"context_line":"                    # Get ports to auto-delete."}],"source_content_type":"text/x-python","patch_set":13,"id":"5a890539_1bfcab71","line":591,"in_reply_to":"5a890539_6ee97419","updated":"2014-12-03 19:34:39.000000000","message":"Thanks, addressed!","commit_id":"417d883251be3c0263492816e8ff6760a5754d18"},{"author":{"_account_id":7448,"name":"Carl Baldwin","email":"carl@ecbaldwin.net","username":"carl-baldwin"},"change_message_id":"cbb65ff8625feed63dce89934b193c9638ffd88e","unresolved":false,"context_lines":[{"line_number":588,"context_line":"                # deletion of a floating IP with certain L3 backends."},{"line_number":589,"context_line":"                self._process_l3_delete(context, id)"},{"line_number":590,"context_line":"                # Locking isn\u0027t necessary. Foreign-key constraints prevent"},{"line_number":591,"context_line":"                # deletion if concurrent creation happens."},{"line_number":592,"context_line":"                with contextlib.nested(lockutils.lock(\u0027db-access\u0027),"},{"line_number":593,"context_line":"                                       session.begin(subtransactions\u003dTrue)):"},{"line_number":594,"context_line":"                    # Get ports to auto-delete."}],"source_content_type":"text/x-python","patch_set":13,"id":"5a890539_6ee97419","line":591,"in_reply_to":"5a890539_e3cbc4a1","updated":"2014-12-03 16:55:23.000000000","message":"Good point, Henry.  This whole in-process lockutils semaphore thing is inherently confusing to the uninitiated as it is.  This does sort of add a bit to the confusion.","commit_id":"417d883251be3c0263492816e8ff6760a5754d18"}]}
