)]}'
{"neutron/agent/common/ovs_lib.py":[{"author":{"_account_id":13995,"name":"Nate Johnston","email":"nate.johnston@redhat.com","username":"natejohnston"},"change_message_id":"b4d0600f21767f40ffa94061ed03660dce2d1c3a","unresolved":false,"context_lines":[{"line_number":627,"context_line":"        # a race condition between delete of the \u0027replace_port\u0027 and the"},{"line_number":628,"context_line":"        # \u0027db_find\u0027 here. So here will sometimes not get the port from the"},{"line_number":629,"context_line":"        # bridge, and we lost the flows for it. So we just retry 10"},{"line_number":630,"context_line":"        # times in 2 seconds to ensure that."},{"line_number":631,"context_line":"        for _i in range(0, 10):"},{"line_number":632,"context_line":"            ports \u003d self.ovsdb.db_find("},{"line_number":633,"context_line":"                \u0027Interface\u0027, (\u0027external_ids\u0027, \u0027\u003d\u0027, {\u0027iface-id\u0027: port_id}),"}],"source_content_type":"text/x-python","patch_set":6,"id":"ffd0ebdf_5cee2289","line":630,"updated":"2019-01-03 12:47:36.000000000","message":"In general I am against set timers to avoid race conditions because in production sometimes even 2 seconds is not enough, and all we\u0027ve done is made a function slower, covered up the issue, and  not fixed the underlying cause.  \n\nBut that being said, I understand that my view is idealistic and in complex systems like Neutron it is not always possible to avoid race conditions, and we have to handle them gracefully.","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"ec13ac28826e95418a696617ea0b9899f5a85437","unresolved":false,"context_lines":[{"line_number":627,"context_line":"        # a race condition between delete of the \u0027replace_port\u0027 and the"},{"line_number":628,"context_line":"        # \u0027db_find\u0027 here. So here will sometimes not get the port from the"},{"line_number":629,"context_line":"        # bridge, and we lost the flows for it. So we just retry 10"},{"line_number":630,"context_line":"        # times in 2 seconds to ensure that."},{"line_number":631,"context_line":"        for _i in range(0, 10):"},{"line_number":632,"context_line":"            ports \u003d self.ovsdb.db_find("},{"line_number":633,"context_line":"                \u0027Interface\u0027, (\u0027external_ids\u0027, \u0027\u003d\u0027, {\u0027iface-id\u0027: port_id}),"}],"source_content_type":"text/x-python","patch_set":6,"id":"ffd0ebdf_ac04a6c7","line":630,"in_reply_to":"ffd0ebdf_5cee2289","updated":"2019-01-04 12:03:48.000000000","message":"Yes, it is true. A simple retry does not always help. But it is simple.\nOr maybe refactor that \u0027replace_port\u0027 method will be a better potential solution.","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"740fd508267daf08c4f9e5f5ab07728acf2e88ab","unresolved":false,"context_lines":[{"line_number":627,"context_line":"        # a race condition between delete of the \u0027replace_port\u0027 and the"},{"line_number":628,"context_line":"        # \u0027db_find\u0027 here. So here will sometimes not get the port from the"},{"line_number":629,"context_line":"        # bridge, and we lost the flows for it. So we just retry 10"},{"line_number":630,"context_line":"        # times in 2 seconds to ensure that."},{"line_number":631,"context_line":"        for _i in range(0, 10):"},{"line_number":632,"context_line":"            ports \u003d self.ovsdb.db_find("},{"line_number":633,"context_line":"                \u0027Interface\u0027, (\u0027external_ids\u0027, \u0027\u003d\u0027, {\u0027iface-id\u0027: port_id}),"}],"source_content_type":"text/x-python","patch_set":6,"id":"ffd0ebdf_fddc9719","line":630,"in_reply_to":"ffd0ebdf_ac04a6c7","updated":"2019-01-04 16:40:05.000000000","message":"I question whether addressing race conditions in a library like this is appropriate. That feels like something the user of the library should handle, especially since the proposed solution involves retries, a counter, and a timer. I actually agree Nate\u0027s sentiment here. If there\u0027s a way we can refactor replace_port to deal with this case I would prefer to see that.","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":13995,"name":"Nate Johnston","email":"nate.johnston@redhat.com","username":"natejohnston"},"change_message_id":"7d123a6ddc8820536a444c56bd8e2ccaab1f3760","unresolved":false,"context_lines":[{"line_number":627,"context_line":"        # a race condition between delete of the \u0027replace_port\u0027 and the"},{"line_number":628,"context_line":"        # \u0027db_find\u0027 here. So here will sometimes not get the port from the"},{"line_number":629,"context_line":"        # bridge, and we lost the flows for it. So we just retry 10"},{"line_number":630,"context_line":"        # times in 2 seconds to ensure that."},{"line_number":631,"context_line":"        for _i in range(0, 10):"},{"line_number":632,"context_line":"            ports \u003d self.ovsdb.db_find("},{"line_number":633,"context_line":"                \u0027Interface\u0027, (\u0027external_ids\u0027, \u0027\u003d\u0027, {\u0027iface-id\u0027: port_id}),"}],"source_content_type":"text/x-python","patch_set":6,"id":"dfd5e7cf_7118f8d2","line":630,"in_reply_to":"ffd0ebdf_fddc9719","updated":"2019-01-04 23:04:25.000000000","message":"+1 to refactoring replace_port.","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":13995,"name":"Nate Johnston","email":"nate.johnston@redhat.com","username":"natejohnston"},"change_message_id":"b4d0600f21767f40ffa94061ed03660dce2d1c3a","unresolved":false,"context_lines":[{"line_number":628,"context_line":"        # \u0027db_find\u0027 here. So here will sometimes not get the port from the"},{"line_number":629,"context_line":"        # bridge, and we lost the flows for it. So we just retry 10"},{"line_number":630,"context_line":"        # times in 2 seconds to ensure that."},{"line_number":631,"context_line":"        for _i in range(0, 10):"},{"line_number":632,"context_line":"            ports \u003d self.ovsdb.db_find("},{"line_number":633,"context_line":"                \u0027Interface\u0027, (\u0027external_ids\u0027, \u0027\u003d\u0027, {\u0027iface-id\u0027: port_id}),"},{"line_number":634,"context_line":"                (\u0027external_ids\u0027, \u0027!\u003d\u0027, {\u0027attached-mac\u0027: \u0027\u0027}),"}],"source_content_type":"text/x-python","patch_set":6,"id":"ffd0ebdf_fc02763e","line":631,"updated":"2019-01-03 12:47:36.000000000","message":"Declare a \"VIF_PORT_FETCH_MAX_ATTEMPTS \u003d 10\" constant or something like it, and use it here.","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"a8302c3a45e3bb0b402f820ced6d0bb46713d8fb","unresolved":false,"context_lines":[{"line_number":628,"context_line":"        # \u0027db_find\u0027 here. So here will sometimes not get the port from the"},{"line_number":629,"context_line":"        # bridge, and we lost the flows for it. So we just retry 10"},{"line_number":630,"context_line":"        # times in 2 seconds to ensure that."},{"line_number":631,"context_line":"        for _i in range(0, 10):"},{"line_number":632,"context_line":"            ports \u003d self.ovsdb.db_find("},{"line_number":633,"context_line":"                \u0027Interface\u0027, (\u0027external_ids\u0027, \u0027\u003d\u0027, {\u0027iface-id\u0027: port_id}),"},{"line_number":634,"context_line":"                (\u0027external_ids\u0027, \u0027!\u003d\u0027, {\u0027attached-mac\u0027: \u0027\u0027}),"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_e5a839dc","line":631,"in_reply_to":"ffd0ebdf_fc02763e","updated":"2019-01-25 03:11:12.000000000","message":"Done","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"ec13ac28826e95418a696617ea0b9899f5a85437","unresolved":false,"context_lines":[{"line_number":628,"context_line":"        # \u0027db_find\u0027 here. So here will sometimes not get the port from the"},{"line_number":629,"context_line":"        # bridge, and we lost the flows for it. So we just retry 10"},{"line_number":630,"context_line":"        # times in 2 seconds to ensure that."},{"line_number":631,"context_line":"        for _i in range(0, 10):"},{"line_number":632,"context_line":"            ports \u003d self.ovsdb.db_find("},{"line_number":633,"context_line":"                \u0027Interface\u0027, (\u0027external_ids\u0027, \u0027\u003d\u0027, {\u0027iface-id\u0027: port_id}),"},{"line_number":634,"context_line":"                (\u0027external_ids\u0027, \u0027!\u003d\u0027, {\u0027attached-mac\u0027: \u0027\u0027}),"}],"source_content_type":"text/x-python","patch_set":6,"id":"ffd0ebdf_ecfcee3f","line":631,"in_reply_to":"ffd0ebdf_fc02763e","updated":"2019-01-04 12:03:48.000000000","message":"Looks good, will do it in next patch set.","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":13995,"name":"Nate Johnston","email":"nate.johnston@redhat.com","username":"natejohnston"},"change_message_id":"b4d0600f21767f40ffa94061ed03660dce2d1c3a","unresolved":false,"context_lines":[{"line_number":644,"context_line":"                LOG.debug(\"Port %s has VifPort %s\", port_id, ovs_vif_port)"},{"line_number":645,"context_line":"                return ovs_vif_port"},{"line_number":646,"context_line":"            LOG.debug(\"Port %s may process under the \""},{"line_number":647,"context_line":"                      \"replace procedure, retry...\","},{"line_number":648,"context_line":"                      port_id)"},{"line_number":649,"context_line":"            time.sleep(0.2)"},{"line_number":650,"context_line":"        # port is really deleted from the bridge."}],"source_content_type":"text/x-python","patch_set":6,"id":"ffd0ebdf_1c009a34","line":647,"updated":"2019-01-03 12:47:36.000000000","message":"An operator looking at logs is not going to necessarily need to know about the replace procedure here.  I would say \"Port %s not found, retrying fetch for race condition avoidance, try %d of %d\".  The last bit would add transparency about the number of attempts and the max so that it might be easier to track in the logs.","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"a8302c3a45e3bb0b402f820ced6d0bb46713d8fb","unresolved":false,"context_lines":[{"line_number":644,"context_line":"                LOG.debug(\"Port %s has VifPort %s\", port_id, ovs_vif_port)"},{"line_number":645,"context_line":"                return ovs_vif_port"},{"line_number":646,"context_line":"            LOG.debug(\"Port %s may process under the \""},{"line_number":647,"context_line":"                      \"replace procedure, retry...\","},{"line_number":648,"context_line":"                      port_id)"},{"line_number":649,"context_line":"            time.sleep(0.2)"},{"line_number":650,"context_line":"        # port is really deleted from the bridge."}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_259f21b5","line":647,"in_reply_to":"ffd0ebdf_1c009a34","updated":"2019-01-25 03:11:12.000000000","message":"Done","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"ec13ac28826e95418a696617ea0b9899f5a85437","unresolved":false,"context_lines":[{"line_number":644,"context_line":"                LOG.debug(\"Port %s has VifPort %s\", port_id, ovs_vif_port)"},{"line_number":645,"context_line":"                return ovs_vif_port"},{"line_number":646,"context_line":"            LOG.debug(\"Port %s may process under the \""},{"line_number":647,"context_line":"                      \"replace procedure, retry...\","},{"line_number":648,"context_line":"                      port_id)"},{"line_number":649,"context_line":"            time.sleep(0.2)"},{"line_number":650,"context_line":"        # port is really deleted from the bridge."}],"source_content_type":"text/x-python","patch_set":6,"id":"ffd0ebdf_4c009a35","line":647,"in_reply_to":"ffd0ebdf_1c009a34","updated":"2019-01-04 12:03:48.000000000","message":"Looks good, will do it in next patch set.","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":13995,"name":"Nate Johnston","email":"nate.johnston@redhat.com","username":"natejohnston"},"change_message_id":"b4d0600f21767f40ffa94061ed03660dce2d1c3a","unresolved":false,"context_lines":[{"line_number":646,"context_line":"            LOG.debug(\"Port %s may process under the \""},{"line_number":647,"context_line":"                      \"replace procedure, retry...\","},{"line_number":648,"context_line":"                      port_id)"},{"line_number":649,"context_line":"            time.sleep(0.2)"},{"line_number":650,"context_line":"        # port is really deleted from the bridge."},{"line_number":651,"context_line":"        LOG.info(\"Port %(port_id)s not present in bridge %(br_name)s\","},{"line_number":652,"context_line":"                 {\u0027port_id\u0027: port_id, \u0027br_name\u0027: self.br_name})"}],"source_content_type":"text/x-python","patch_set":6,"id":"ffd0ebdf_bcfcee3e","line":649,"updated":"2019-01-03 12:47:36.000000000","message":"Declare a \"VIF_PORT_FETCH_INTERVAL \u003d 0.2\" constant or something like it and use it here.","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"a8302c3a45e3bb0b402f820ced6d0bb46713d8fb","unresolved":false,"context_lines":[{"line_number":646,"context_line":"            LOG.debug(\"Port %s may process under the \""},{"line_number":647,"context_line":"                      \"replace procedure, retry...\","},{"line_number":648,"context_line":"                      port_id)"},{"line_number":649,"context_line":"            time.sleep(0.2)"},{"line_number":650,"context_line":"        # port is really deleted from the bridge."},{"line_number":651,"context_line":"        LOG.info(\"Port %(port_id)s not present in bridge %(br_name)s\","},{"line_number":652,"context_line":"                 {\u0027port_id\u0027: port_id, \u0027br_name\u0027: self.br_name})"}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_059c5dbe","line":649,"in_reply_to":"ffd0ebdf_bcfcee3e","updated":"2019-01-25 03:11:12.000000000","message":"Done","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"ec13ac28826e95418a696617ea0b9899f5a85437","unresolved":false,"context_lines":[{"line_number":646,"context_line":"            LOG.debug(\"Port %s may process under the \""},{"line_number":647,"context_line":"                      \"replace procedure, retry...\","},{"line_number":648,"context_line":"                      port_id)"},{"line_number":649,"context_line":"            time.sleep(0.2)"},{"line_number":650,"context_line":"        # port is really deleted from the bridge."},{"line_number":651,"context_line":"        LOG.info(\"Port %(port_id)s not present in bridge %(br_name)s\","},{"line_number":652,"context_line":"                 {\u0027port_id\u0027: port_id, \u0027br_name\u0027: self.br_name})"}],"source_content_type":"text/x-python","patch_set":6,"id":"ffd0ebdf_2c03d644","line":649,"in_reply_to":"ffd0ebdf_bcfcee3e","updated":"2019-01-04 12:03:48.000000000","message":"Looks good, will do it in next patch set.","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":13995,"name":"Nate Johnston","email":"nate.johnston@redhat.com","username":"natejohnston"},"change_message_id":"b4d0600f21767f40ffa94061ed03660dce2d1c3a","unresolved":false,"context_lines":[{"line_number":647,"context_line":"                      \"replace procedure, retry...\","},{"line_number":648,"context_line":"                      port_id)"},{"line_number":649,"context_line":"            time.sleep(0.2)"},{"line_number":650,"context_line":"        # port is really deleted from the bridge."},{"line_number":651,"context_line":"        LOG.info(\"Port %(port_id)s not present in bridge %(br_name)s\","},{"line_number":652,"context_line":"                 {\u0027port_id\u0027: port_id, \u0027br_name\u0027: self.br_name})"},{"line_number":653,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"ffd0ebdf_dcf9b24d","line":650,"updated":"2019-01-03 12:47:36.000000000","message":"The main worry I have about this function is that we\u0027re essentially introducing a sleep(2) in cases where we\u0027re looking for a port that is actually deleted.  Do you know how frequently this happens - not just in the replace_port scenario described here, but in general?","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"},{"author":{"_account_id":9531,"name":"liuyulong","display_name":"LIU Yulong","email":"i@liuyulong.me","username":"LIU-Yulong"},"change_message_id":"ec13ac28826e95418a696617ea0b9899f5a85437","unresolved":false,"context_lines":[{"line_number":647,"context_line":"                      \"replace procedure, retry...\","},{"line_number":648,"context_line":"                      port_id)"},{"line_number":649,"context_line":"            time.sleep(0.2)"},{"line_number":650,"context_line":"        # port is really deleted from the bridge."},{"line_number":651,"context_line":"        LOG.info(\"Port %(port_id)s not present in bridge %(br_name)s\","},{"line_number":652,"context_line":"                 {\u0027port_id\u0027: port_id, \u0027br_name\u0027: self.br_name})"},{"line_number":653,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"ffd0ebdf_8c13e20d","line":650,"in_reply_to":"ffd0ebdf_dcf9b24d","updated":"2019-01-04 12:03:48.000000000","message":"The main issue was originally coming from the testing of:\nhttps://bugs.launchpad.net/neutron/+bug/1798475\nEvery time there has a ping loss, we will see that \"Port not present in bridge\" log. So I dug the code and found this race condition. The gateway port may be deleted during the \u0027replace_port\u0027 procedure. For now, I do not have other scenario. But there is a lot of such log in zuul output:\nhttp://logstash.openstack.org/#dashboard/file/logstash.json?query\u003dmessage%3A%20%5C%22not%20present%20in%20bridge%5C%22%20AND%20message%3A%20%5C%22Port%5C%22\nIt can happen 345566 per 12h. Real interesting, right?\n\nAnd why 2 seconds, according to the replace_port log I noticed that it mostly take 0.2s to finish the action, maybe it is not true in other cases. So 2 seconds after 10 times retry.\n\nFor that delete port case, I think we can add a new separated method for it without the retry.","commit_id":"690761d290445eab8d25bb9605e49d7ceff9cce8"}]}
