)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":6876,"name":"stephen-ma","email":"stephenbma43@gmail.com","username":"stephen-ma"},"change_message_id":"1ca285a4cee78aea3a0319d4b5f4c4cc6869aa16","unresolved":false,"context_lines":[{"line_number":14,"context_line":"from running in parallel."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"Change-Id: Ib8c1c81936196b4962df6af59c1a2aba4124b1cf"},{"line_number":17,"context_line":"Closes-Bug: 1235800"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":1,"id":"1ae5cdf2_c64826cf","line":17,"updated":"2014-06-09 15:40:28.000000000","message":"1325800, not 1235800","commit_id":"6e196c1098747a9d872cbbbea8b9351b8f60937c"},{"author":{"_account_id":7805,"name":"Li Ma","email":"skywalker.nick@gmail.com","username":"Nick"},"change_message_id":"6b5bf4749c1c7c626065659ca929f76d39d90c21","unresolved":false,"context_lines":[{"line_number":14,"context_line":"from running in parallel."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"Change-Id: Ib8c1c81936196b4962df6af59c1a2aba4124b1cf"},{"line_number":17,"context_line":"Closes-Bug: 1235800"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":1,"id":"1ae5cdf2_b0bdf9d9","line":17,"in_reply_to":"1ae5cdf2_c64826cf","updated":"2014-06-10 01:46:11.000000000","message":"Pls change it in the revised commitment.","commit_id":"6e196c1098747a9d872cbbbea8b9351b8f60937c"}],"neutron/agent/l3_agent.py":[{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"62e47b39780fee8f58a42203b81224d461d805ca","unresolved":false,"context_lines":[{"line_number":733,"context_line":"        LOG.debug(_(\u0027Got router deleted notification for %s\u0027), router_id)"},{"line_number":734,"context_line":"        self.removed_routers.add(router_id)"},{"line_number":735,"context_line":""},{"line_number":736,"context_line":"    @lockutils.synchronized(\u0027l3-agent\u0027, \u0027neutron-\u0027)"},{"line_number":737,"context_line":"    def routers_updated(self, context, routers):"},{"line_number":738,"context_line":"        \"\"\"Deal with routers modification and creation RPC message.\"\"\""},{"line_number":739,"context_line":"        LOG.debug(_(\u0027Got routers updated notification :%s\u0027), routers)"}],"source_content_type":"text/x-python","patch_set":1,"id":"1ae5cdf2_08030a74","line":736,"updated":"2014-06-09 08:27:04.000000000","message":"remove this","commit_id":"6e196c1098747a9d872cbbbea8b9351b8f60937c"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"62e47b39780fee8f58a42203b81224d461d805ca","unresolved":false,"context_lines":[{"line_number":810,"context_line":"            if self.updated_routers:"},{"line_number":811,"context_line":"                # We\u0027re capturing and clearing the list, and will"},{"line_number":812,"context_line":"                # process the \"captured\" updates in this loop,"},{"line_number":813,"context_line":"                # and any updates that happen due to a context switch"},{"line_number":814,"context_line":"                # will be picked up on the next pass."},{"line_number":815,"context_line":"                updated_routers \u003d set(self.updated_routers)"},{"line_number":816,"context_line":"                self.updated_routers.clear()"}],"source_content_type":"text/x-python","patch_set":1,"id":"1ae5cdf2_88d71aed","line":813,"updated":"2014-06-09 08:27:04.000000000","message":"Replace 815 and 816 with:\n\n updated_routers_ref \u003d self.updated_routers\n self.updated_routers \u003d set()\n updated_routers \u003d set(update_routers_ref)","commit_id":"6e196c1098747a9d872cbbbea8b9351b8f60937c"},{"author":{"_account_id":6876,"name":"stephen-ma","email":"stephenbma43@gmail.com","username":"stephen-ma"},"change_message_id":"f490a20fa9f82bf0de4c3f0e03be8ab23c3adea6","unresolved":false,"context_lines":[{"line_number":810,"context_line":"            if self.updated_routers:"},{"line_number":811,"context_line":"                # We\u0027re capturing and clearing the list, and will"},{"line_number":812,"context_line":"                # process the \"captured\" updates in this loop,"},{"line_number":813,"context_line":"                # and any updates that happen due to a context switch"},{"line_number":814,"context_line":"                # will be picked up on the next pass."},{"line_number":815,"context_line":"                updated_routers \u003d set(self.updated_routers)"},{"line_number":816,"context_line":"                self.updated_routers.clear()"}],"source_content_type":"text/x-python","patch_set":1,"id":"1ae5cdf2_fed7f9eb","line":813,"in_reply_to":"1ae5cdf2_14885821","updated":"2014-06-12 03:37:36.000000000","message":"Thanks for the explaining how this works.  I am going to abandon this patch.","commit_id":"6e196c1098747a9d872cbbbea8b9351b8f60937c"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"e11695a72640e262cea0255fda30d7dbe0061fc0","unresolved":false,"context_lines":[{"line_number":810,"context_line":"            if self.updated_routers:"},{"line_number":811,"context_line":"                # We\u0027re capturing and clearing the list, and will"},{"line_number":812,"context_line":"                # process the \"captured\" updates in this loop,"},{"line_number":813,"context_line":"                # and any updates that happen due to a context switch"},{"line_number":814,"context_line":"                # will be picked up on the next pass."},{"line_number":815,"context_line":"                updated_routers \u003d set(self.updated_routers)"},{"line_number":816,"context_line":"                self.updated_routers.clear()"}],"source_content_type":"text/x-python","patch_set":1,"id":"1ae5cdf2_d340dc37","line":813,"in_reply_to":"1ae5cdf2_1ffec86b","updated":"2014-06-09 19:09:38.000000000","message":"Rather than calling clear on the set assigned to the object, it just assigns a new set to the object, while having a local pointer to the old one. It then processes the old one here so whichever one \u0027update_routers\u0027 had changed will get processed either in this call or the next one. \n\nNo set has \u0027clear\u0027 called on it so the data loss condition should not exist if I understood the race condition you described.","commit_id":"6e196c1098747a9d872cbbbea8b9351b8f60937c"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"2f8fb4d48be767cd4185039df3da8a3828b89dc1","unresolved":false,"context_lines":[{"line_number":810,"context_line":"            if self.updated_routers:"},{"line_number":811,"context_line":"                # We\u0027re capturing and clearing the list, and will"},{"line_number":812,"context_line":"                # process the \"captured\" updates in this loop,"},{"line_number":813,"context_line":"                # and any updates that happen due to a context switch"},{"line_number":814,"context_line":"                # will be picked up on the next pass."},{"line_number":815,"context_line":"                updated_routers \u003d set(self.updated_routers)"},{"line_number":816,"context_line":"                self.updated_routers.clear()"}],"source_content_type":"text/x-python","patch_set":1,"id":"1ae5cdf2_1ffec86b","line":813,"in_reply_to":"1ae5cdf2_88d71aed","updated":"2014-06-09 18:57:23.000000000","message":"Hi Kevin. Can you please explain me why the code you suggested should avoid the race condition? To me it seems that it would expose the same problem as the current code. Thanks","commit_id":"6e196c1098747a9d872cbbbea8b9351b8f60937c"},{"author":{"_account_id":6876,"name":"stephen-ma","email":"stephenbma43@gmail.com","username":"stephen-ma"},"change_message_id":"41599a196693f6636874e36359afc11b2604bd9f","unresolved":false,"context_lines":[{"line_number":810,"context_line":"            if self.updated_routers:"},{"line_number":811,"context_line":"                # We\u0027re capturing and clearing the list, and will"},{"line_number":812,"context_line":"                # process the \"captured\" updates in this loop,"},{"line_number":813,"context_line":"                # and any updates that happen due to a context switch"},{"line_number":814,"context_line":"                # will be picked up on the next pass."},{"line_number":815,"context_line":"                updated_routers \u003d set(self.updated_routers)"},{"line_number":816,"context_line":"                self.updated_routers.clear()"}],"source_content_type":"text/x-python","patch_set":1,"id":"1ae5cdf2_e67fcb64","line":813,"in_reply_to":"1ae5cdf2_d340dc37","updated":"2014-06-10 02:41:18.000000000","message":"Hi Kevin, Both routers_updated and _rpc_loop may still be reference the same updated_routers object at the same time:\n\n_rpc_loop at updated_routers \u003d set(updated_routers_ref) and\nrouters_updated at  line 744 -- if both functions are entered at the same time.\n\nSo the same race condition will still occur.","commit_id":"6e196c1098747a9d872cbbbea8b9351b8f60937c"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"047041535f6dd314f7233275b2d6679326eb1db4","unresolved":false,"context_lines":[{"line_number":810,"context_line":"            if self.updated_routers:"},{"line_number":811,"context_line":"                # We\u0027re capturing and clearing the list, and will"},{"line_number":812,"context_line":"                # process the \"captured\" updates in this loop,"},{"line_number":813,"context_line":"                # and any updates that happen due to a context switch"},{"line_number":814,"context_line":"                # will be picked up on the next pass."},{"line_number":815,"context_line":"                updated_routers \u003d set(self.updated_routers)"},{"line_number":816,"context_line":"                self.updated_routers.clear()"}],"source_content_type":"text/x-python","patch_set":1,"id":"1ae5cdf2_14885821","line":813,"in_reply_to":"1ae5cdf2_e67fcb64","updated":"2014-06-10 08:16:57.000000000","message":"For that to happen, routers_updated would have to start the call at line 744\nso it got the pointer to the old updated_routers before _rpc_loop swapped out the reference to a new set, but not update it until after _rpc_loop calls set() on the old set reference. Perhaps if these were running in parallel threads and the core the router_udpated thread was on was really slow.\n\nHowever, this brings up another question. _rpc_loop is just a loopingcall which is based on an eventlet greenthread. These aren\u0027t really running in parallel. One thread executes until it hits a blocking call (file-system access, network access, etc) or a sleep and then it yields and another thread starts execution. \n\nUnder those conditions, I don\u0027t even see the original reported race condition here. Once routers_updated starts, that function will have sole execution until it finishes because it makes no yielding calls. Similarly, once _rpc_loop is executing, it should run from 801 to 817 without yielding to any other thread.\n\nAre you certain that there is a race condition here?\n\n\nHere is an example of similar logic that mangles shared data structures but fixes them by the end of the function: http://paste.openstack.org/show/83487/","commit_id":"6e196c1098747a9d872cbbbea8b9351b8f60937c"}]}
