)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"4ced6b07301580379784aba0c4da632953a7a4e3","unresolved":false,"context_lines":[{"line_number":14,"context_line":"latest data (revision number), then passing the StaleDataError and"},{"line_number":15,"context_line":"writing to database successfully."},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"This patch does extend the process of transaction, then the second"},{"line_number":18,"context_line":"transaction will always open before the first transaction had been"},{"line_number":19,"context_line":"close."},{"line_number":20,"context_line":""},{"line_number":21,"context_line":"Change-Id: I9ff2bf830c0c9d1114833d33603622f447ee7ca2"},{"line_number":22,"context_line":"Closes-bug: #1532696"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":4,"id":"9ad45d7e_ed7c6622","line":19,"range":{"start_line":17,"start_character":0,"end_line":19,"end_character":6},"updated":"2016-08-09 08:43:05.000000000","message":"This seems not quite correct description of the fix. Should it say that check for duplicate rule was moved under transaction to prevent race condition?","commit_id":"e7e3806b6ff9ed8c0f82209ddeee7d6bb4c8462b"},{"author":{"_account_id":19935,"name":"Anh Tran","email":"anhtt@vn.fujitsu.com","username":"trananhkma"},"change_message_id":"43526c41017e0ca01dec86bd4f449a1ab91285c0","unresolved":false,"context_lines":[{"line_number":14,"context_line":"latest data (revision number), then passing the StaleDataError and"},{"line_number":15,"context_line":"writing to database successfully."},{"line_number":16,"context_line":""},{"line_number":17,"context_line":"This patch does extend the process of transaction, then the second"},{"line_number":18,"context_line":"transaction will always open before the first transaction had been"},{"line_number":19,"context_line":"close."},{"line_number":20,"context_line":""},{"line_number":21,"context_line":"Change-Id: I9ff2bf830c0c9d1114833d33603622f447ee7ca2"},{"line_number":22,"context_line":"Closes-bug: #1532696"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":4,"id":"9ad45d7e_52642ae4","line":19,"range":{"start_line":17,"start_character":0,"end_line":19,"end_character":6},"in_reply_to":"9ad45d7e_ed7c6622","updated":"2016-08-09 09:57:28.000000000","message":"Done","commit_id":"e7e3806b6ff9ed8c0f82209ddeee7d6bb4c8462b"},{"author":{"_account_id":13717,"name":"Inessa Vasilevskaya","email":"ivasilevskaya@mirantis.com","username":"ivasilevskaya"},"change_message_id":"2df78d1a591993b3830301be3004a490322ae884","unresolved":false,"context_lines":[{"line_number":6,"context_line":""},{"line_number":7,"context_line":"Prevent duplicate SG rules in \u0027concurrent requests\u0027 case"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Problem: The process of transaction is too short."},{"line_number":10,"context_line":"In case of concurrent requests, both requests can pass all tests"},{"line_number":11,"context_line":"and going to write to database. Sometimes the transaction of first"},{"line_number":12,"context_line":"request closed before the transaction of the second request has been"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"9ad45d7e_92734215","line":9,"range":{"start_line":9,"start_character":0,"end_line":9,"end_character":49},"updated":"2016-08-09 10:07:23.000000000","message":"Nit: I\u0027d remove this line, it doesn\u0027t help much to understand the issue. Your description + link to the bug is more than enough.","commit_id":"10855e75ee7e6f0c89bdf7f73dce65aa82008c00"}],"neutron/db/securitygroups_db.py":[{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"5804d20c3e9611f135c1137e3e07f18e596b3cf9","unresolved":false,"context_lines":[{"line_number":381,"context_line":"            if validate:"},{"line_number":382,"context_line":"                self._validate_security_group_rule(context,"},{"line_number":383,"context_line":"                                                   security_group_rule)"},{"line_number":384,"context_line":"                self._check_for_duplicate_rules_in_db(context,"},{"line_number":385,"context_line":"                                                      security_group_rule)"},{"line_number":386,"context_line":""},{"line_number":387,"context_line":"            rule_dict \u003d security_group_rule[\u0027security_group_rule\u0027]"}],"source_content_type":"text/x-python","patch_set":1,"id":"dada55a8_363201f3","line":384,"range":{"start_line":384,"start_character":21,"end_line":384,"end_character":53},"updated":"2016-07-26 08:22:25.000000000","message":"Actually, I think that only this function call needs to be inserted into the transaction in order to fix the race condition you\u0027re fixing here. I think of this in a similar way I think of \"try-except blocks should encapsulate the smallest pieces of code possible\". What do you think?\n\nAlso, it\u0027s very much worth commenting here that StaleDataError can be raised in case of a concurrent execution, which is not necessarily caught by this functioni call.","commit_id":"4f065dfbdc53205d6bae3a40320271d16f9d45ed"},{"author":{"_account_id":19935,"name":"Anh Tran","email":"anhtt@vn.fujitsu.com","username":"trananhkma"},"change_message_id":"736e0ba51acc1905414bba92928086a8ac6025d4","unresolved":false,"context_lines":[{"line_number":381,"context_line":"            if validate:"},{"line_number":382,"context_line":"                self._validate_security_group_rule(context,"},{"line_number":383,"context_line":"                                                   security_group_rule)"},{"line_number":384,"context_line":"                self._check_for_duplicate_rules_in_db(context,"},{"line_number":385,"context_line":"                                                      security_group_rule)"},{"line_number":386,"context_line":""},{"line_number":387,"context_line":"            rule_dict \u003d security_group_rule[\u0027security_group_rule\u0027]"}],"source_content_type":"text/x-python","patch_set":1,"id":"dada55a8_930ad188","line":384,"range":{"start_line":384,"start_character":21,"end_line":384,"end_character":53},"in_reply_to":"dada55a8_363201f3","updated":"2016-07-26 12:30:20.000000000","message":"\u003e only this function call needs to be inserted into the transaction\n\nThat\u0027s exactly what I wanted to do. But I don\u0027t want to change the workflow of code, so I changed smallest pieces of code possible. Do you have any suggestion for me? :D\n\n\u003e StaleDataError can be raised in case of a concurrent execution, which is not necessarily caught by this functioni call.\n\nYep, the StaleDataError can be raised in the case of a concurrent execution only. In other cases, the function call cannot raise this error.\nWhat do you think? Did I miss something?","commit_id":"4f065dfbdc53205d6bae3a40320271d16f9d45ed"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"ac1695ae86aeb7d81695950a4b63854f9f009195","unresolved":false,"context_lines":[{"line_number":381,"context_line":"            if validate:"},{"line_number":382,"context_line":"                self._validate_security_group_rule(context,"},{"line_number":383,"context_line":"                                                   security_group_rule)"},{"line_number":384,"context_line":"                self._check_for_duplicate_rules_in_db(context,"},{"line_number":385,"context_line":"                                                      security_group_rule)"},{"line_number":386,"context_line":""},{"line_number":387,"context_line":"            rule_dict \u003d security_group_rule[\u0027security_group_rule\u0027]"}],"source_content_type":"text/x-python","patch_set":1,"id":"dada55a8_669dd965","line":384,"range":{"start_line":384,"start_character":21,"end_line":384,"end_character":53},"in_reply_to":"dada55a8_930ad188","updated":"2016-07-26 12:34:11.000000000","message":"Yes - don\u0027t be afraid to change the workflow of the code :) rearranging it so that _check_for_duplicate_rules_in_db is right before the creation is acceptable IMO.\n\nI don\u0027t think you missed anything - StaleDataError pops when the data that was read when the session was created is no longer relevant when trying to commit (i.e. it\u0027s stale), and this only happens on concurrent executions (even from other neutron-server processes). For the other cases, _check_for_duplicate_rules_in_db should be enough to catch them.","commit_id":"4f065dfbdc53205d6bae3a40320271d16f9d45ed"},{"author":{"_account_id":7787,"name":"Kevin Benton","email":"kevin@benton.pub","username":"blak111"},"change_message_id":"ea3ecbc0a0cd01b5d40ccbd972c183a58ea0a51a","unresolved":false,"context_lines":[{"line_number":385,"context_line":"        }"},{"line_number":386,"context_line":"        self._registry_notify(resources.SECURITY_GROUP_RULE,"},{"line_number":387,"context_line":"                              events.BEFORE_CREATE,"},{"line_number":388,"context_line":"                              exc_cls\u003dext_sg.SecurityGroupConflict, **kwargs)"},{"line_number":389,"context_line":""},{"line_number":390,"context_line":"        with context.session.begin(subtransactions\u003dTrue):"},{"line_number":391,"context_line":"            if validate:"}],"source_content_type":"text/x-python","patch_set":4,"id":"bacf61ea_76be6e00","line":388,"updated":"2016-08-03 17:46:45.000000000","message":"BEFORE_CREATE is meant for the type of hooks that do validation. There is no guarantee on BEFORE events that it will be created so this is okay.","commit_id":"e7e3806b6ff9ed8c0f82209ddeee7d6bb4c8462b"},{"author":{"_account_id":12444,"name":"John Schwarz","email":"jschwarz@redhat.com","username":"jschwarz"},"change_message_id":"7bd133cb1a546f8a003a3ed642cc52f8d5fbeb7a","unresolved":false,"context_lines":[{"line_number":383,"context_line":"            \u0027context\u0027: context,"},{"line_number":384,"context_line":"            \u0027security_group_rule\u0027: rule_dict"},{"line_number":385,"context_line":"        }"},{"line_number":386,"context_line":"        self._registry_notify(resources.SECURITY_GROUP_RULE,"},{"line_number":387,"context_line":"                              events.BEFORE_CREATE,"},{"line_number":388,"context_line":"                              exc_cls\u003dext_sg.SecurityGroupConflict, **kwargs)"},{"line_number":389,"context_line":""},{"line_number":390,"context_line":"        with context.session.begin(subtransactions\u003dTrue):"},{"line_number":391,"context_line":"            if validate:"}],"source_content_type":"text/x-python","patch_set":4,"id":"bacf61ea_adec22f4","line":388,"range":{"start_line":386,"start_character":8,"end_line":388,"end_character":77},"updated":"2016-08-03 15:00:06.000000000","message":"Looking at this now, I\u0027m unsure if this must happen after all the verifications (and after the _check_for... call). Can you make sure with some neutron.callback people that this is OK?","commit_id":"e7e3806b6ff9ed8c0f82209ddeee7d6bb4c8462b"}]}
