)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"dfb9de31b4794de417b7f5ec5a7c07b2e4bd8f10","unresolved":false,"context_lines":[{"line_number":6,"context_line":""},{"line_number":7,"context_line":"Refactor retry mechanism used in some DB operations"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Add helper that will allow to restart whole transaction"},{"line_number":10,"context_line":"in case it needs certain operation to be repeated."},{"line_number":11,"context_line":"This is a workaround for REPEATABLE READ problem where"},{"line_number":12,"context_line":"retrying logic will not work because queries inside transation"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa81d914_3e472c21","line":9,"updated":"2015-01-28 19:13:44.000000000","message":"whole -\u003e the whole","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"4fddf1f00d63321c2cad93c8ccc8d20abe4d7ff9","unresolved":false,"context_lines":[{"line_number":6,"context_line":""},{"line_number":7,"context_line":"Refactor retry mechanism used in some DB operations"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Add helper that will allow to restart whole transaction"},{"line_number":10,"context_line":"in case it needs certain operation to be repeated."},{"line_number":11,"context_line":"This is a workaround for REPEATABLE READ problem where"},{"line_number":12,"context_line":"retrying logic will not work because queries inside transation"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa81d914_65482b2e","line":9,"in_reply_to":"fa81d914_3e472c21","updated":"2015-01-28 21:09:32.000000000","message":"Done","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"dfb9de31b4794de417b7f5ec5a7c07b2e4bd8f10","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Refactor retry mechanism used in some DB operations"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Add helper that will allow to restart whole transaction"},{"line_number":10,"context_line":"in case it needs certain operation to be repeated."},{"line_number":11,"context_line":"This is a workaround for REPEATABLE READ problem where"},{"line_number":12,"context_line":"retrying logic will not work because queries inside transation"},{"line_number":13,"context_line":"will not see updates made by other transactions."}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa81d914_5e4b002b","line":10,"updated":"2015-01-28 19:13:44.000000000","message":"certain -\u003e a certain","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"4fddf1f00d63321c2cad93c8ccc8d20abe4d7ff9","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Refactor retry mechanism used in some DB operations"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Add helper that will allow to restart whole transaction"},{"line_number":10,"context_line":"in case it needs certain operation to be repeated."},{"line_number":11,"context_line":"This is a workaround for REPEATABLE READ problem where"},{"line_number":12,"context_line":"retrying logic will not work because queries inside transation"},{"line_number":13,"context_line":"will not see updates made by other transactions."}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa81d914_a55223db","line":10,"in_reply_to":"fa81d914_5e4b002b","updated":"2015-01-28 21:09:32.000000000","message":"Done","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"dfb9de31b4794de417b7f5ec5a7c07b2e4bd8f10","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Add helper that will allow to restart whole transaction"},{"line_number":10,"context_line":"in case it needs certain operation to be repeated."},{"line_number":11,"context_line":"This is a workaround for REPEATABLE READ problem where"},{"line_number":12,"context_line":"retrying logic will not work because queries inside transation"},{"line_number":13,"context_line":"will not see updates made by other transactions."},{"line_number":14,"context_line":"So run every attempt in separate transaction."}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa81d914_de5e10e9","line":11,"updated":"2015-01-28 19:13:44.000000000","message":"for -\u003e for the","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"4fddf1f00d63321c2cad93c8ccc8d20abe4d7ff9","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Add helper that will allow to restart whole transaction"},{"line_number":10,"context_line":"in case it needs certain operation to be repeated."},{"line_number":11,"context_line":"This is a workaround for REPEATABLE READ problem where"},{"line_number":12,"context_line":"retrying logic will not work because queries inside transation"},{"line_number":13,"context_line":"will not see updates made by other transactions."},{"line_number":14,"context_line":"So run every attempt in separate transaction."}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa81d914_c55e37e9","line":11,"in_reply_to":"fa81d914_de5e10e9","updated":"2015-01-28 21:09:32.000000000","message":"Done","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"dfb9de31b4794de417b7f5ec5a7c07b2e4bd8f10","unresolved":false,"context_lines":[{"line_number":9,"context_line":"Add helper that will allow to restart whole transaction"},{"line_number":10,"context_line":"in case it needs certain operation to be repeated."},{"line_number":11,"context_line":"This is a workaround for REPEATABLE READ problem where"},{"line_number":12,"context_line":"retrying logic will not work because queries inside transation"},{"line_number":13,"context_line":"will not see updates made by other transactions."},{"line_number":14,"context_line":"So run every attempt in separate transaction."},{"line_number":15,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa81d914_5e72207d","line":12,"updated":"2015-01-28 19:13:44.000000000","message":"transation -\u003e a transaction","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"4fddf1f00d63321c2cad93c8ccc8d20abe4d7ff9","unresolved":false,"context_lines":[{"line_number":9,"context_line":"Add helper that will allow to restart whole transaction"},{"line_number":10,"context_line":"in case it needs certain operation to be repeated."},{"line_number":11,"context_line":"This is a workaround for REPEATABLE READ problem where"},{"line_number":12,"context_line":"retrying logic will not work because queries inside transation"},{"line_number":13,"context_line":"will not see updates made by other transactions."},{"line_number":14,"context_line":"So run every attempt in separate transaction."},{"line_number":15,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa81d914_e5633baf","line":12,"in_reply_to":"fa81d914_5e72207d","updated":"2015-01-28 21:09:32.000000000","message":"Done","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"dfb9de31b4794de417b7f5ec5a7c07b2e4bd8f10","unresolved":false,"context_lines":[{"line_number":11,"context_line":"This is a workaround for REPEATABLE READ problem where"},{"line_number":12,"context_line":"retrying logic will not work because queries inside transation"},{"line_number":13,"context_line":"will not see updates made by other transactions."},{"line_number":14,"context_line":"So run every attempt in separate transaction."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"Change-Id: I68f9ae8019879725df58f5da2c83bb699a548255"},{"line_number":17,"context_line":"Closes-Bug: #1382064"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa81d914_1e10a800","line":14,"updated":"2015-01-28 19:13:44.000000000","message":"So -\u003e So,\n\nin -\u003e in a","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"4fddf1f00d63321c2cad93c8ccc8d20abe4d7ff9","unresolved":false,"context_lines":[{"line_number":11,"context_line":"This is a workaround for REPEATABLE READ problem where"},{"line_number":12,"context_line":"retrying logic will not work because queries inside transation"},{"line_number":13,"context_line":"will not see updates made by other transactions."},{"line_number":14,"context_line":"So run every attempt in separate transaction."},{"line_number":15,"context_line":""},{"line_number":16,"context_line":"Change-Id: I68f9ae8019879725df58f5da2c83bb699a548255"},{"line_number":17,"context_line":"Closes-Bug: #1382064"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"fa81d914_05592ffe","line":14,"in_reply_to":"fa81d914_1e10a800","updated":"2015-01-28 21:09:32.000000000","message":"Done","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"}],"neutron/db/api.py":[{"author":{"_account_id":12524,"name":"Zengfa Gao","email":"zengfa.gao@hp.com","username":"zengfagao"},"change_message_id":"fd7574cb3dda3c5d5d52c9b68f74fa30f8e15815","unresolved":false,"context_lines":[{"line_number":53,"context_line":"        self.inner_exc \u003d inner_exc"},{"line_number":54,"context_line":""},{"line_number":55,"context_line":""},{"line_number":56,"context_line":"MAX_RETRY_ATTEMPTS \u003d 10"},{"line_number":57,"context_line":""},{"line_number":58,"context_line":""},{"line_number":59,"context_line":"def db_retry_on_request(f, max_retries\u003dMAX_RETRY_ATTEMPTS):"}],"source_content_type":"text/x-python","patch_set":2,"id":"1a930d6b_e20810dc","line":56,"updated":"2015-01-27 00:05:17.000000000","message":"This hard-code number may be moved to top, or property file.","commit_id":"6f73f5a8cf88db2e0ce7a7c856942e572335c34e"},{"author":{"_account_id":12524,"name":"Zengfa Gao","email":"zengfa.gao@hp.com","username":"zengfagao"},"change_message_id":"fd7574cb3dda3c5d5d52c9b68f74fa30f8e15815","unresolved":false,"context_lines":[{"line_number":69,"context_line":"            try:"},{"line_number":70,"context_line":"                return f(*args, **kwargs)"},{"line_number":71,"context_line":"            except RetryRequest as e:"},{"line_number":72,"context_line":"                attempts +\u003d 1"},{"line_number":73,"context_line":"                if attempts \u003e max_retries:"},{"line_number":74,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":75,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":2,"id":"1a930d6b_82702c73","line":72,"updated":"2015-01-27 00:05:17.000000000","message":"We initial attempts to 1, then +1 for the first time. It will be 2 for the first fails.","commit_id":"6f73f5a8cf88db2e0ce7a7c856942e572335c34e"},{"author":{"_account_id":12524,"name":"Zengfa Gao","email":"zengfa.gao@hp.com","username":"zengfagao"},"change_message_id":"fd7574cb3dda3c5d5d52c9b68f74fa30f8e15815","unresolved":false,"context_lines":[{"line_number":80,"context_line":"                          \"\u0027%(func_name)s\u0027, attempt %(attempt)s\","},{"line_number":81,"context_line":"                          {\u0027func_name\u0027: f.__name__,"},{"line_number":82,"context_line":"                           \u0027attempt\u0027: attempts})"},{"line_number":83,"context_line":"    return wrapper"}],"source_content_type":"text/x-python","patch_set":2,"id":"1a930d6b_a20288b1","line":83,"updated":"2015-01-27 00:05:17.000000000","message":"Unit testing is needed for this function.","commit_id":"6f73f5a8cf88db2e0ce7a7c856942e572335c34e"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"0e58e7487ef02845440fa501db5ef399258bf9a5","unresolved":false,"context_lines":[{"line_number":80,"context_line":"                          \"\u0027%(func_name)s\u0027, attempt %(attempt)s\","},{"line_number":81,"context_line":"                          {\u0027func_name\u0027: f.__name__,"},{"line_number":82,"context_line":"                           \u0027attempt\u0027: attempts})"},{"line_number":83,"context_line":"    return wrapper"}],"source_content_type":"text/x-python","patch_set":2,"id":"1a930d6b_b199e17a","line":83,"in_reply_to":"1a930d6b_a20288b1","updated":"2015-01-27 12:50:15.000000000","message":"The wrapper is implicitly tested by test_helpers","commit_id":"6f73f5a8cf88db2e0ce7a7c856942e572335c34e"},{"author":{"_account_id":12524,"name":"Zengfa Gao","email":"zengfa.gao@hp.com","username":"zengfagao"},"change_message_id":"1bdfa23d009b7b1bccfd6dcc4eedc8a160c8981c","unresolved":false,"context_lines":[{"line_number":63,"context_line":"    \"\"\""},{"line_number":64,"context_line":"    @functools.wraps(f)"},{"line_number":65,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":66,"context_line":"        attempts \u003d 1"},{"line_number":67,"context_line":"        while True:"},{"line_number":68,"context_line":"            try:"},{"line_number":69,"context_line":"                return f(*args, **kwargs)"}],"source_content_type":"text/x-python","patch_set":3,"id":"1a930d6b_cb0b117b","line":66,"updated":"2015-01-27 15:53:08.000000000","message":"Should attemps to start with 0? or move attemps after LOG.debug. Otherwise the LOG.warn will have wrong attemps count.","commit_id":"84569a3a879128b98bb39e22e0785408f85398b4"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"9343ac11c27fa3d289a555d27d20a1c375110d38","unresolved":false,"context_lines":[{"line_number":63,"context_line":"    \"\"\""},{"line_number":64,"context_line":"    @functools.wraps(f)"},{"line_number":65,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":66,"context_line":"        attempts \u003d 1"},{"line_number":67,"context_line":"        while True:"},{"line_number":68,"context_line":"            try:"},{"line_number":69,"context_line":"                return f(*args, **kwargs)"}],"source_content_type":"text/x-python","patch_set":3,"id":"1a930d6b_e67004a6","line":66,"in_reply_to":"1a930d6b_cb0b117b","updated":"2015-01-27 16:00:04.000000000","message":"ok, i\u0027ll fix log statement, it indeed will write attempts being 1 more than in fact was done. But i think starting with 1 is clearer in this case (human-friendly)","commit_id":"84569a3a879128b98bb39e22e0785408f85398b4"},{"author":{"_account_id":4395,"name":"Aaron Rosen","email":"aaronorosen@gmail.com","username":"arosen"},"change_message_id":"3f4d76989dacd51634004595d93db4e81c2a0867","unresolved":false,"context_lines":[{"line_number":56,"context_line":""},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"def db_retry_on_request(f, max_attempts\u003dMAX_ATTEMPTS):"},{"line_number":59,"context_line":"    \"\"\"Decorator to retry a DB API call if inner code requests so."},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    This might be needed if inner code detects that it need to"},{"line_number":62,"context_line":"    restart whole transaction."}],"source_content_type":"text/x-python","patch_set":4,"id":"1a930d6b_ec11c304","line":59,"updated":"2015-01-27 16:47:15.000000000","message":"more so if inner code raises an exception?","commit_id":"30962b802400a53f78d019180e2097ff393c818e"},{"author":{"_account_id":4395,"name":"Aaron Rosen","email":"aaronorosen@gmail.com","username":"arosen"},"change_message_id":"ec00dfa4b6ba11739ca1058f0e7a0374094bfd36","unresolved":false,"context_lines":[{"line_number":56,"context_line":""},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"def db_retry_on_request(f, max_attempts\u003dMAX_ATTEMPTS):"},{"line_number":59,"context_line":"    \"\"\"Decorator to retry a DB API call if inner code requests so."},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    This might be needed if inner code detects that it need to"},{"line_number":62,"context_line":"    restart whole transaction."}],"source_content_type":"text/x-python","patch_set":4,"id":"fa81d914_add96985","line":59,"in_reply_to":"1a930d6b_8c34bffc","updated":"2015-01-27 18:53:26.000000000","message":"I was just saying this would be more honest if it say: Retry require if decorated function raises any exception. Right?","commit_id":"30962b802400a53f78d019180e2097ff393c818e"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"c928396c518851bac6a8bf03d4dc3f31b310173d","unresolved":false,"context_lines":[{"line_number":56,"context_line":""},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"def db_retry_on_request(f, max_attempts\u003dMAX_ATTEMPTS):"},{"line_number":59,"context_line":"    \"\"\"Decorator to retry a DB API call if inner code requests so."},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    This might be needed if inner code detects that it need to"},{"line_number":62,"context_line":"    restart whole transaction."}],"source_content_type":"text/x-python","patch_set":4,"id":"1a930d6b_8c34bffc","line":59,"in_reply_to":"1a930d6b_ec11c304","updated":"2015-01-27 16:54:15.000000000","message":"Any other exception will be raised through","commit_id":"30962b802400a53f78d019180e2097ff393c818e"},{"author":{"_account_id":4395,"name":"Aaron Rosen","email":"aaronorosen@gmail.com","username":"arosen"},"change_message_id":"3f4d76989dacd51634004595d93db4e81c2a0867","unresolved":false,"context_lines":[{"line_number":67,"context_line":"        while True:"},{"line_number":68,"context_line":"            try:"},{"line_number":69,"context_line":"                return f(*args, **kwargs)"},{"line_number":70,"context_line":"            except RetryRequest as e:"},{"line_number":71,"context_line":"                if attempts \u003e\u003d max_attempts:"},{"line_number":72,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":73,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":4,"id":"1a930d6b_cc8167fc","line":70,"updated":"2015-01-27 16:47:15.000000000","message":"I don\u0027t think defining this RetryRequest that subclasses Exception really adds anything. Are there explicit exceptions we can except  on here rather than all of them? I was thinking it might be nice to pass an additional arg to db_retry_on_request() that contains a list of exceptions we want to retry on.","commit_id":"30962b802400a53f78d019180e2097ff393c818e"},{"author":{"_account_id":4395,"name":"Aaron Rosen","email":"aaronorosen@gmail.com","username":"arosen"},"change_message_id":"ec00dfa4b6ba11739ca1058f0e7a0374094bfd36","unresolved":false,"context_lines":[{"line_number":67,"context_line":"        while True:"},{"line_number":68,"context_line":"            try:"},{"line_number":69,"context_line":"                return f(*args, **kwargs)"},{"line_number":70,"context_line":"            except RetryRequest as e:"},{"line_number":71,"context_line":"                if attempts \u003e\u003d max_attempts:"},{"line_number":72,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":73,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa81d914_adca496c","line":70,"in_reply_to":"1a930d6b_2c5cab4a","updated":"2015-01-27 18:53:26.000000000","message":"Right but it\u0027s not really a specific exception. RetryRequest \u003d\u003d Exception. The thing i want to avoid here is what if there is a ValueError/Attribute error that is raised in the code. As it currently stands we\u0027ll just retry that right?","commit_id":"30962b802400a53f78d019180e2097ff393c818e"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"c928396c518851bac6a8bf03d4dc3f31b310173d","unresolved":false,"context_lines":[{"line_number":67,"context_line":"        while True:"},{"line_number":68,"context_line":"            try:"},{"line_number":69,"context_line":"                return f(*args, **kwargs)"},{"line_number":70,"context_line":"            except RetryRequest as e:"},{"line_number":71,"context_line":"                if attempts \u003e\u003d max_attempts:"},{"line_number":72,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":73,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":4,"id":"1a930d6b_2c5cab4a","line":70,"in_reply_to":"1a930d6b_cc8167fc","updated":"2015-01-27 16:54:15.000000000","message":"I was thinking about that too, but here\u0027s my consideration:\n\nThe code that does retries could be quite \u0027far\u0027 from db_retry_on_request invocation point, so upper code like ml2 plugin may not eve import it directly. That\u0027s why i decided to go with specific exception.","commit_id":"30962b802400a53f78d019180e2097ff393c818e"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"1f38e2fc2d38d62040a6224a917006e803f11156","unresolved":false,"context_lines":[{"line_number":67,"context_line":"        while True:"},{"line_number":68,"context_line":"            try:"},{"line_number":69,"context_line":"                return f(*args, **kwargs)"},{"line_number":70,"context_line":"            except RetryRequest as e:"},{"line_number":71,"context_line":"                if attempts \u003e\u003d max_attempts:"},{"line_number":72,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":73,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":4,"id":"fa81d914_2d48f22c","line":70,"in_reply_to":"fa81d914_adca496c","updated":"2015-01-28 13:41:41.000000000","message":"Any exception class will create specific exception (regardless if it is a subclass of Exception). ValueError/AttributeError could only be caught here if they were derived from RetryRequest","commit_id":"30962b802400a53f78d019180e2097ff393c818e"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"dfb9de31b4794de417b7f5ec5a7c07b2e4bd8f10","unresolved":false,"context_lines":[{"line_number":25,"context_line":"LOG \u003d logging.getLogger(__name__)"},{"line_number":26,"context_line":"_FACADE \u003d None"},{"line_number":27,"context_line":""},{"line_number":28,"context_line":"MAX_ATTEMPTS \u003d 10"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"def _create_facade_lazily():"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_7e1d240f","line":28,"updated":"2015-01-28 19:13:44.000000000","message":"Max attempts of what?  I get why the kwarg parameter is named like this, but a constant doesn\u0027t have the context of the method.  Suggest: MAX_RETRIES","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"4fddf1f00d63321c2cad93c8ccc8d20abe4d7ff9","unresolved":false,"context_lines":[{"line_number":25,"context_line":"LOG \u003d logging.getLogger(__name__)"},{"line_number":26,"context_line":"_FACADE \u003d None"},{"line_number":27,"context_line":""},{"line_number":28,"context_line":"MAX_ATTEMPTS \u003d 10"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":""},{"line_number":31,"context_line":"def _create_facade_lazily():"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_e5a6dbc0","line":28,"in_reply_to":"fa81d914_7e1d240f","updated":"2015-01-28 21:09:32.000000000","message":"the word \u0027retry\u0027 is a little bit confusing:  if max_retries \u003d 1, do we do 1 attempt or 2 attempts?\nI guess, we do 2 attempts, one of which is a REtry. It\u0027s simple, of course, but still requires some efforts to deal with +-1\n\nI\u0027ll change the name, but the logic will be different (a bit more complex)","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":4395,"name":"Aaron Rosen","email":"aaronorosen@gmail.com","username":"arosen"},"change_message_id":"19cee955c4d0b4c01e542b53d352453c7e12e628","unresolved":false,"context_lines":[{"line_number":55,"context_line":"        self.inner_exc \u003d inner_exc"},{"line_number":56,"context_line":""},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"def db_retry_on_request(f, max_attempts\u003dMAX_ATTEMPTS):"},{"line_number":59,"context_line":"    \"\"\"Decorator to retry a DB API call if inner code requests so."},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    This might be needed if inner code detects that it need to"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_b4d89b1e","line":58,"updated":"2015-01-28 19:37:07.000000000","message":"We could also use this: https://pypi.python.org/pypi/retrying which a few other openstack projects are already using to retry things.","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"4fddf1f00d63321c2cad93c8ccc8d20abe4d7ff9","unresolved":false,"context_lines":[{"line_number":55,"context_line":"        self.inner_exc \u003d inner_exc"},{"line_number":56,"context_line":""},{"line_number":57,"context_line":""},{"line_number":58,"context_line":"def db_retry_on_request(f, max_attempts\u003dMAX_ATTEMPTS):"},{"line_number":59,"context_line":"    \"\"\"Decorator to retry a DB API call if inner code requests so."},{"line_number":60,"context_line":""},{"line_number":61,"context_line":"    This might be needed if inner code detects that it need to"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_4095d53e","line":58,"in_reply_to":"fa81d914_b4d89b1e","updated":"2015-01-28 21:09:32.000000000","message":"Good to know, thanks. \nI\u0027ve looked at the implementation of the lib, it does much more than we need, but lacks logging that is helpful, IMO.\n\nI\u0027m not sure though if it makes sense to add this dependency considering that we only need very limited part of retrying functionality.","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"dfb9de31b4794de417b7f5ec5a7c07b2e4bd8f10","unresolved":false,"context_lines":[{"line_number":70,"context_line":"                          {\u0027func_name\u0027: f.__name__,"},{"line_number":71,"context_line":"                           \u0027attempt\u0027: attempt})"},{"line_number":72,"context_line":"                return f(*args, **kwargs)"},{"line_number":73,"context_line":"            except RetryRequest as e:"},{"line_number":74,"context_line":"                if attempt \u003e\u003d max_attempts:"},{"line_number":75,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":76,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_be2cfcac","line":73,"updated":"2015-01-28 19:13:44.000000000","message":"I don\u0027t think it\u0027s safe to effectively ignore exceptions raised before the maximum number of attempts has been reached.  At the least, the intermediate exceptions should be logged at the debug level.","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"4fddf1f00d63321c2cad93c8ccc8d20abe4d7ff9","unresolved":false,"context_lines":[{"line_number":70,"context_line":"                          {\u0027func_name\u0027: f.__name__,"},{"line_number":71,"context_line":"                           \u0027attempt\u0027: attempt})"},{"line_number":72,"context_line":"                return f(*args, **kwargs)"},{"line_number":73,"context_line":"            except RetryRequest as e:"},{"line_number":74,"context_line":"                if attempt \u003e\u003d max_attempts:"},{"line_number":75,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":76,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_80e7cd3f","line":73,"in_reply_to":"fa81d914_be2cfcac","updated":"2015-01-28 21:09:32.000000000","message":"I think it is logged above (L68-71).  Attempt \u003e 1 in a log message means then exceptions were raised.","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"dfb9de31b4794de417b7f5ec5a7c07b2e4bd8f10","unresolved":false,"context_lines":[{"line_number":71,"context_line":"                           \u0027attempt\u0027: attempt})"},{"line_number":72,"context_line":"                return f(*args, **kwargs)"},{"line_number":73,"context_line":"            except RetryRequest as e:"},{"line_number":74,"context_line":"                if attempt \u003e\u003d max_attempts:"},{"line_number":75,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":76,"context_line":"                                 \"after %(attempts)s attempts\"),"},{"line_number":77,"context_line":"                             {\u0027func_name\u0027: f.__name__,"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_1e36e852","line":74,"updated":"2015-01-28 19:13:44.000000000","message":"Please add testing to ensure that this code path (when retries are exceeded) is tested.","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"4fddf1f00d63321c2cad93c8ccc8d20abe4d7ff9","unresolved":false,"context_lines":[{"line_number":71,"context_line":"                           \u0027attempt\u0027: attempt})"},{"line_number":72,"context_line":"                return f(*args, **kwargs)"},{"line_number":73,"context_line":"            except RetryRequest as e:"},{"line_number":74,"context_line":"                if attempt \u003e\u003d max_attempts:"},{"line_number":75,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":76,"context_line":"                                 \"after %(attempts)s attempts\"),"},{"line_number":77,"context_line":"                             {\u0027func_name\u0027: f.__name__,"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_c0d0e555","line":74,"in_reply_to":"fa81d914_1e36e852","updated":"2015-01-28 21:09:32.000000000","message":"Done","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"dfb9de31b4794de417b7f5ec5a7c07b2e4bd8f10","unresolved":false,"context_lines":[{"line_number":76,"context_line":"                                 \"after %(attempts)s attempts\"),"},{"line_number":77,"context_line":"                             {\u0027func_name\u0027: f.__name__,"},{"line_number":78,"context_line":"                              \u0027attempts\u0027: max_attempts})"},{"line_number":79,"context_line":"                    raise e.inner_exc"},{"line_number":80,"context_line":""},{"line_number":81,"context_line":"    return wrapper"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_71c1d57f","line":79,"updated":"2015-01-28 19:13:44.000000000","message":"Won\u0027t raising here fail to indicate the original location of the exception and make troubleshooting more difficult?  Consider investigating a mechanism that ensures a proper re-raise.","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"4fddf1f00d63321c2cad93c8ccc8d20abe4d7ff9","unresolved":false,"context_lines":[{"line_number":76,"context_line":"                                 \"after %(attempts)s attempts\"),"},{"line_number":77,"context_line":"                             {\u0027func_name\u0027: f.__name__,"},{"line_number":78,"context_line":"                              \u0027attempts\u0027: max_attempts})"},{"line_number":79,"context_line":"                    raise e.inner_exc"},{"line_number":80,"context_line":""},{"line_number":81,"context_line":"    return wrapper"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_40c4f591","line":79,"in_reply_to":"fa81d914_71c1d57f","updated":"2015-01-28 21:09:32.000000000","message":"Done","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"c3e5f10e3655b378716dad81a07777fe44e64742","unresolved":false,"context_lines":[{"line_number":27,"context_line":"LOG \u003d logging.getLogger(__name__)"},{"line_number":28,"context_line":"_FACADE \u003d None"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":"MAX_RETRIES \u003d 10"},{"line_number":31,"context_line":""},{"line_number":32,"context_line":""},{"line_number":33,"context_line":"def _create_facade_lazily():"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_f9eba775","line":30,"updated":"2015-02-03 21:30:32.000000000","message":"Would it make more sense to set this with a config flag rather than hard-coding it? I know it can be overridden when the decorator is invoked, but having callers of the decorator overriding the default seems like it would be the exception not the norm.  This seems like something an operator may be interested in tweaking. 10 seems sort of arbitrary.","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":4395,"name":"Aaron Rosen","email":"aaronorosen@gmail.com","username":"arosen"},"change_message_id":"d00d35b3a7025e24214c6c473fe3501488efbeb9","unresolved":false,"context_lines":[{"line_number":27,"context_line":"LOG \u003d logging.getLogger(__name__)"},{"line_number":28,"context_line":"_FACADE \u003d None"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":"MAX_RETRIES \u003d 10"},{"line_number":31,"context_line":""},{"line_number":32,"context_line":""},{"line_number":33,"context_line":"def _create_facade_lazily():"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_56d39503","line":30,"in_reply_to":"da86d52c_961b4d72","updated":"2015-02-04 05:46:01.000000000","message":"I agree, I don\u0027t think it makes much sense to make this configurable as well.","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":4187,"name":"Ryan Tidwell","email":"rtidwell@suse.com","username":"ryan-tidwell"},"change_message_id":"46909cb4fcefc5e30c98d938d1bd3767eb849033","unresolved":false,"context_lines":[{"line_number":27,"context_line":"LOG \u003d logging.getLogger(__name__)"},{"line_number":28,"context_line":"_FACADE \u003d None"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":"MAX_RETRIES \u003d 10"},{"line_number":31,"context_line":""},{"line_number":32,"context_line":""},{"line_number":33,"context_line":"def _create_facade_lazily():"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_7e3e94db","line":30,"in_reply_to":"da86d52c_961b4d72","updated":"2015-02-04 18:29:11.000000000","message":"Thanks for the explanation.  Makes sense to me.","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"13be5746f4000bc46c207f9dca5c2b179ee44056","unresolved":false,"context_lines":[{"line_number":27,"context_line":"LOG \u003d logging.getLogger(__name__)"},{"line_number":28,"context_line":"_FACADE \u003d None"},{"line_number":29,"context_line":""},{"line_number":30,"context_line":"MAX_RETRIES \u003d 10"},{"line_number":31,"context_line":""},{"line_number":32,"context_line":""},{"line_number":33,"context_line":"def _create_facade_lazily():"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_961b4d72","line":30,"in_reply_to":"da86d52c_f9eba775","updated":"2015-02-04 05:14:23.000000000","message":"I just don\u0027t think it makes sense to make every constant configurable.\nAccording to stress tests, amount of retries needed to create a network never reach even 5 at very high level of concurrency.\nSo 10 just means that operation should succeed every time.","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":6854,"name":"YAMAMOTO Takashi","email":"yamamoto@midokura.com","username":"yamamoto"},"change_message_id":"1feeb007c1a47a6495ce6c99a2cbfb3aa10c1d9c","unresolved":false,"context_lines":[{"line_number":82,"context_line":"                    # which is contained in \u0027e\u0027"},{"line_number":83,"context_line":"                    six.reraise(type(e.inner_exc),"},{"line_number":84,"context_line":"                                e.inner_exc,"},{"line_number":85,"context_line":"                                sys.exc_info()[2])"},{"line_number":86,"context_line":""},{"line_number":87,"context_line":"    return wrapper"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_d6a305b0","line":85,"updated":"2015-02-04 05:40:04.000000000","message":"this seems to need a trick similar to save_and_reraise_exception.","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":841,"name":"Akihiro Motoki","email":"amotoki@gmail.com","username":"amotoki"},"change_message_id":"f735488bd8153de2337e8dfa0194b66954e82962","unresolved":false,"context_lines":[{"line_number":82,"context_line":"                    # which is contained in \u0027e\u0027"},{"line_number":83,"context_line":"                    six.reraise(type(e.inner_exc),"},{"line_number":84,"context_line":"                                e.inner_exc,"},{"line_number":85,"context_line":"                                sys.exc_info()[2])"},{"line_number":86,"context_line":""},{"line_number":87,"context_line":"    return wrapper"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_ad94408b","line":85,"in_reply_to":"da86d52c_0ce74aad","updated":"2015-02-05 13:17:31.000000000","message":"The difference is that first two arguments point to the inner_exc, so we need to use six.reraise here.","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"08b10b6eff1483d338f264e0e0ee6a754d27b579","unresolved":false,"context_lines":[{"line_number":82,"context_line":"                    # which is contained in \u0027e\u0027"},{"line_number":83,"context_line":"                    six.reraise(type(e.inner_exc),"},{"line_number":84,"context_line":"                                e.inner_exc,"},{"line_number":85,"context_line":"                                sys.exc_info()[2])"},{"line_number":86,"context_line":""},{"line_number":87,"context_line":"    return wrapper"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_0ce74aad","line":85,"in_reply_to":"da86d52c_d6a305b0","updated":"2015-02-04 07:40:09.000000000","message":"six.reraise does proper job with parameters provided","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"c3d46826365daaec0ab9d7d02cb11156d10a1ebd","unresolved":false,"context_lines":[{"line_number":65,"context_line":"    \"\"\""},{"line_number":66,"context_line":"    @functools.wraps(f)"},{"line_number":67,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":68,"context_line":"        for attempt in xrange(1, max_retries + 2):"},{"line_number":69,"context_line":"            try:"},{"line_number":70,"context_line":"                LOG.debug(\"Trying operation \""},{"line_number":71,"context_line":"                          \"\u0027%(func_name)s\u0027, attempt %(attempt)s\","}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_6ed950f2","line":68,"updated":"2015-02-05 19:31:29.000000000","message":"Just make this max_retries + 1 and remove the max_retries + 1 on line 76 below...","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"7bc8b80e47c27c8edc36016b22dc349c90c70029","unresolved":false,"context_lines":[{"line_number":65,"context_line":"    \"\"\""},{"line_number":66,"context_line":"    @functools.wraps(f)"},{"line_number":67,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":68,"context_line":"        for attempt in xrange(1, max_retries + 2):"},{"line_number":69,"context_line":"            try:"},{"line_number":70,"context_line":"                LOG.debug(\"Trying operation \""},{"line_number":71,"context_line":"                          \"\u0027%(func_name)s\u0027, attempt %(attempt)s\","}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_f7a89921","line":68,"in_reply_to":"da86d52c_4b1b8780","updated":"2015-02-06 17:12:50.000000000","message":"I hate this attempt vs retry discussion :)\n\nSee early patchsets.","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"e1e4acb666b2a3717be039fa61316feebdf1bae1","unresolved":false,"context_lines":[{"line_number":65,"context_line":"    \"\"\""},{"line_number":66,"context_line":"    @functools.wraps(f)"},{"line_number":67,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":68,"context_line":"        for attempt in xrange(1, max_retries + 2):"},{"line_number":69,"context_line":"            try:"},{"line_number":70,"context_line":"                LOG.debug(\"Trying operation \""},{"line_number":71,"context_line":"                          \"\u0027%(func_name)s\u0027, attempt %(attempt)s\","}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_baaa9482","line":68,"in_reply_to":"da86d52c_6ed950f2","updated":"2015-02-06 06:42:52.000000000","message":"Not really :)\nThat\u0027s a bit of confusing arithmetics because we go with \u0027retries\u0027 name rather than \u0027attempts\u0027, So we do max_retries+1 attempts, starting from 1, that makes [1, max_retries+2) parameters for xrange","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"51b29d51e241223af2a6e3f731fcd8bc80e8d751","unresolved":false,"context_lines":[{"line_number":65,"context_line":"    \"\"\""},{"line_number":66,"context_line":"    @functools.wraps(f)"},{"line_number":67,"context_line":"    def wrapper(*args, **kwargs):"},{"line_number":68,"context_line":"        for attempt in xrange(1, max_retries + 2):"},{"line_number":69,"context_line":"            try:"},{"line_number":70,"context_line":"                LOG.debug(\"Trying operation \""},{"line_number":71,"context_line":"                          \"\u0027%(func_name)s\u0027, attempt %(attempt)s\","}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_4b1b8780","line":68,"in_reply_to":"da86d52c_baaa9482","updated":"2015-02-06 09:55:27.000000000","message":"Why not defining using max_attempts?","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"c3d46826365daaec0ab9d7d02cb11156d10a1ebd","unresolved":false,"context_lines":[{"line_number":72,"context_line":"                          {\u0027func_name\u0027: f.__name__,"},{"line_number":73,"context_line":"                           \u0027attempt\u0027: attempt})"},{"line_number":74,"context_line":"                return f(*args, **kwargs)"},{"line_number":75,"context_line":"            except RetryRequest as e:"},{"line_number":76,"context_line":"                if attempt \u003e\u003d max_retries + 1:"},{"line_number":77,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":78,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_2eb91879","line":75,"updated":"2015-02-05 19:31:29.000000000","message":"Hmm, so *any* exception wil trigger a retry of the function \"f\" here. Is that really what you want? Shouldn\u0027t we just be attempting to re-execute a query against the database in the case of specific events (e.g. the return of 0 rows updated)? I don\u0027t see how this decorator accomplishes the goal of retrying the function in a brand new database session, though...","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"e1e4acb666b2a3717be039fa61316feebdf1bae1","unresolved":false,"context_lines":[{"line_number":72,"context_line":"                          {\u0027func_name\u0027: f.__name__,"},{"line_number":73,"context_line":"                           \u0027attempt\u0027: attempt})"},{"line_number":74,"context_line":"                return f(*args, **kwargs)"},{"line_number":75,"context_line":"            except RetryRequest as e:"},{"line_number":76,"context_line":"                if attempt \u003e\u003d max_retries + 1:"},{"line_number":77,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":78,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_7a8bbc1e","line":75,"in_reply_to":"da86d52c_2eb91879","updated":"2015-02-06 06:42:52.000000000","message":"No! The fact that RetryRequest is derived from Exception doesn\u0027t cause this to catch any exception!","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"6b56b35382b817605a5a3ae214bd71c825c286ca","unresolved":false,"context_lines":[{"line_number":72,"context_line":"                          {\u0027func_name\u0027: f.__name__,"},{"line_number":73,"context_line":"                           \u0027attempt\u0027: attempt})"},{"line_number":74,"context_line":"                return f(*args, **kwargs)"},{"line_number":75,"context_line":"            except RetryRequest as e:"},{"line_number":76,"context_line":"                if attempt \u003e\u003d max_retries + 1:"},{"line_number":77,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":78,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_7482e7c8","line":75,"in_reply_to":"da86d52c_7a8bbc1e","updated":"2015-02-06 14:03:12.000000000","message":"Doh, sorry, yeah, I had a brain-fart on this one :)","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"},{"author":{"_account_id":1689,"name":"Robert Kukura","email":"rk@theep.net","username":"rkukura"},"change_message_id":"117319dba211846694f6dc9cac2bfe4f88a0a6a4","unresolved":false,"context_lines":[{"line_number":72,"context_line":"                          {\u0027func_name\u0027: f.__name__,"},{"line_number":73,"context_line":"                           \u0027attempt\u0027: attempt})"},{"line_number":74,"context_line":"                return f(*args, **kwargs)"},{"line_number":75,"context_line":"            except RetryRequest as e:"},{"line_number":76,"context_line":"                if attempt \u003e\u003d max_retries + 1:"},{"line_number":77,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":78,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":11,"id":"da86d52c_b4a896dc","line":75,"updated":"2015-02-09 17:41:12.000000000","message":"I see how this will retry transactions where RetryRequest is thrown from the segment allocation code. But when two transactions allocate the same segment concurrently, isn\u0027t this detected in the commit rather than the update? If so, I don\u0027t see how that gets retried. Shouldn\u0027t this also catch and retry the exception thrown when the commit detects a conflict?","commit_id":"f967d23e6cc506f67aea45c288cd5ea0b454698d"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"b85a1aac753c858fc0262fd04dea8ce9549104df","unresolved":false,"context_lines":[{"line_number":72,"context_line":"                          {\u0027func_name\u0027: f.__name__,"},{"line_number":73,"context_line":"                           \u0027attempt\u0027: attempt})"},{"line_number":74,"context_line":"                return f(*args, **kwargs)"},{"line_number":75,"context_line":"            except RetryRequest as e:"},{"line_number":76,"context_line":"                if attempt \u003e\u003d max_retries + 1:"},{"line_number":77,"context_line":"                    LOG.warn(_LW(\"Operation \u0027%(func_name)s\u0027 has failed \""},{"line_number":78,"context_line":"                                 \"after %(attempts)s attempts\"),"}],"source_content_type":"text/x-python","patch_set":11,"id":"da86d52c_1a59845b","line":75,"in_reply_to":"da86d52c_b4a896dc","updated":"2015-02-09 20:15:09.000000000","message":"\u003e  isn\u0027t this detected in the commit rather than the update\n\nNot really. In commit DBDuplicateError could be thrown, but that can\u0027t be used as a retry marker. Also, commit appears much later in code flow than RetryRequest exception is raised, in other words you need to know about retry failures at the level of outer-most transaction. That what we try to avoid with this approach.\n\n\u003e If so, I don\u0027t see how that gets retried\n\nBy simple running whole decorated method again.\n\n\u003e Shouldn\u0027t this also catch and retry the exception thrown when the commit detects a conflict?\n\nThe idea is to do retries only in controllable manner, that\u0027s why i called the exception \u0027RetryRequest\u0027. If decorated method is able to detect conflict - fine, it needs to raise RetryRequest.\n\nBut if we\u0027re talking about compound methods where part of logic is supposed to run within a subtransaction, there\u0027s no way to predict a place where you have to detect the conflict.\nNot to say conflict detection method by examining \u0027update\u0027 result is the best.","commit_id":"f967d23e6cc506f67aea45c288cd5ea0b454698d"}],"neutron/db/sqlalchemyutils.py":[{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"a6ac83035ae0f085a0a6bacedf4e5d7761601048","unresolved":false,"context_lines":[{"line_number":111,"context_line":"    return query"},{"line_number":112,"context_line":""},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"class RetryRequestException(Exception):"},{"line_number":115,"context_line":"    def __init__(self, inner_exc):"},{"line_number":116,"context_line":"        self.inner \u003d inner_exc"},{"line_number":117,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_6213bbb8","line":114,"updated":"2015-01-22 15:23:28.000000000","message":"This class (Like StopIeration, GeneratorExit and LoopingCallDone) is used a signal in its normal application not as an error so its name should be RetryRequest?","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"75ac8abdc3e4fe18b83241be11bad09821414dcb","unresolved":false,"context_lines":[{"line_number":111,"context_line":"    return query"},{"line_number":112,"context_line":""},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"class RetryRequestException(Exception):"},{"line_number":115,"context_line":"    def __init__(self, inner_exc):"},{"line_number":116,"context_line":"        self.inner \u003d inner_exc"},{"line_number":117,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_422d88fd","line":114,"in_reply_to":"1a930d6b_6213bbb8","updated":"2015-01-27 12:50:08.000000000","message":"Done","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"a6ac83035ae0f085a0a6bacedf4e5d7761601048","unresolved":false,"context_lines":[{"line_number":115,"context_line":"    def __init__(self, inner_exc):"},{"line_number":116,"context_line":"        self.inner \u003d inner_exc"},{"line_number":117,"context_line":""},{"line_number":118,"context_line":"MAX_RETRY_ATTEMPTS \u003d 10"},{"line_number":119,"context_line":""},{"line_number":120,"context_line":""},{"line_number":121,"context_line":"def _db_retry_on_request(f):"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_4ff8a849","line":118,"updated":"2015-01-22 15:23:28.000000000","message":"it means the decorator attempts 10 times or retries 10 times :)\n\n\"MAX_DB_ATTEMPTS\" (from helpers) seems clearer","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"75ac8abdc3e4fe18b83241be11bad09821414dcb","unresolved":false,"context_lines":[{"line_number":115,"context_line":"    def __init__(self, inner_exc):"},{"line_number":116,"context_line":"        self.inner \u003d inner_exc"},{"line_number":117,"context_line":""},{"line_number":118,"context_line":"MAX_RETRY_ATTEMPTS \u003d 10"},{"line_number":119,"context_line":""},{"line_number":120,"context_line":""},{"line_number":121,"context_line":"def _db_retry_on_request(f):"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_a238ec3d","line":118,"in_reply_to":"1a930d6b_4ff8a849","updated":"2015-01-27 12:50:08.000000000","message":"Done","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"a6ac83035ae0f085a0a6bacedf4e5d7761601048","unresolved":false,"context_lines":[{"line_number":118,"context_line":"MAX_RETRY_ATTEMPTS \u003d 10"},{"line_number":119,"context_line":""},{"line_number":120,"context_line":""},{"line_number":121,"context_line":"def _db_retry_on_request(f):"},{"line_number":122,"context_line":"    \"\"\"Decorator to retry a DB API call if inner code requests so."},{"line_number":123,"context_line":""},{"line_number":124,"context_line":"    This might be needed if inner code detects that it need to"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_2f219cfb","line":121,"updated":"2015-01-22 15:23:28.000000000","message":"According to usage, it should a public method.\n\nAccording to code, _db_retry_on_request could be used to retry non-db related method (to move in neutron/common/utils?). If you do so, i would provide as an argument the number of attempts.","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"},{"author":{"_account_id":6788,"name":"Rossella Sblendido","email":"rsblendido@suse.com","username":"rossella-o"},"change_message_id":"0847b7ddbb29ef9773029fe5c4ac67ba826289a6","unresolved":false,"context_lines":[{"line_number":118,"context_line":"MAX_RETRY_ATTEMPTS \u003d 10"},{"line_number":119,"context_line":""},{"line_number":120,"context_line":""},{"line_number":121,"context_line":"def _db_retry_on_request(f):"},{"line_number":122,"context_line":"    \"\"\"Decorator to retry a DB API call if inner code requests so."},{"line_number":123,"context_line":""},{"line_number":124,"context_line":"    This might be needed if inner code detects that it need to"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_42c6914a","line":121,"in_reply_to":"1a930d6b_2f219cfb","updated":"2015-01-23 15:49:03.000000000","message":"+1 for making it more general. I wrote a similar decorator. see _retry_function in [1] ...I am happy to have it in a common place.\n\n[1] https://review.openstack.org/#/c/100963/32/neutron/db/db_base_plugin_v2.py","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"75ac8abdc3e4fe18b83241be11bad09821414dcb","unresolved":false,"context_lines":[{"line_number":118,"context_line":"MAX_RETRY_ATTEMPTS \u003d 10"},{"line_number":119,"context_line":""},{"line_number":120,"context_line":""},{"line_number":121,"context_line":"def _db_retry_on_request(f):"},{"line_number":122,"context_line":"    \"\"\"Decorator to retry a DB API call if inner code requests so."},{"line_number":123,"context_line":""},{"line_number":124,"context_line":"    This might be needed if inner code detects that it need to"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_e23d942c","line":121,"in_reply_to":"1a930d6b_42c6914a","updated":"2015-01-27 12:50:08.000000000","message":"i\u0027m moving it into neutron.db.api","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"a6ac83035ae0f085a0a6bacedf4e5d7761601048","unresolved":false,"context_lines":[{"line_number":127,"context_line":"    @functools.wraps(f)"},{"line_number":128,"context_line":"    def wrapped(*args, **kwargs):"},{"line_number":129,"context_line":"        attempts \u003d 1"},{"line_number":130,"context_line":"        while True:"},{"line_number":131,"context_line":"            try:"},{"line_number":132,"context_line":"                return f(*args, **kwargs)"},{"line_number":133,"context_line":"            except RetryRequestException as e:"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_ef3f9423","line":130,"updated":"2015-01-22 15:23:28.000000000","message":"using a for loop seems more readable and safer as it ensures \"by pattern\" a finite number of attempts","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"75ac8abdc3e4fe18b83241be11bad09821414dcb","unresolved":false,"context_lines":[{"line_number":127,"context_line":"    @functools.wraps(f)"},{"line_number":128,"context_line":"    def wrapped(*args, **kwargs):"},{"line_number":129,"context_line":"        attempts \u003d 1"},{"line_number":130,"context_line":"        while True:"},{"line_number":131,"context_line":"            try:"},{"line_number":132,"context_line":"                return f(*args, **kwargs)"},{"line_number":133,"context_line":"            except RetryRequestException as e:"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_024700bd","line":130,"in_reply_to":"1a930d6b_ef3f9423","updated":"2015-01-27 12:50:08.000000000","message":"Done","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"},{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"a6ac83035ae0f085a0a6bacedf4e5d7761601048","unresolved":false,"context_lines":[{"line_number":142,"context_line":"                          \"\u0027%(func_name)s\u0027\","},{"line_number":143,"context_line":"                          {\u0027func_name\u0027: f.__name__})"},{"line_number":144,"context_line":"                # Retry!"},{"line_number":145,"context_line":"                time.sleep(0.5)"},{"line_number":146,"context_line":"                continue"},{"line_number":147,"context_line":"    functools.update_wrapper(wrapped, f)"},{"line_number":148,"context_line":"    return wrapped"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_22e8d30f","line":145,"updated":"2015-01-22 15:23:28.000000000","message":"L145 ouh, beurk :) the duration should a constant or provided as an argument with a default value?","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"75ac8abdc3e4fe18b83241be11bad09821414dcb","unresolved":false,"context_lines":[{"line_number":142,"context_line":"                          \"\u0027%(func_name)s\u0027\","},{"line_number":143,"context_line":"                          {\u0027func_name\u0027: f.__name__})"},{"line_number":144,"context_line":"                # Retry!"},{"line_number":145,"context_line":"                time.sleep(0.5)"},{"line_number":146,"context_line":"                continue"},{"line_number":147,"context_line":"    functools.update_wrapper(wrapped, f)"},{"line_number":148,"context_line":"    return wrapped"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_021e20bb","line":145,"in_reply_to":"1a930d6b_22e8d30f","updated":"2015-01-27 12:50:08.000000000","message":"I think i\u0027ll just remove it for not. I don\u0027t think it makes much sense to wait.\nInitially this code is a copy-paste from nova","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"}],"neutron/plugins/ml2/drivers/helpers.py":[{"author":{"_account_id":8124,"name":"cbrandily","email":"zzelle@gmail.com","username":"cbrandily"},"change_message_id":"a6ac83035ae0f085a0a6bacedf4e5d7761601048","unresolved":false,"context_lines":[{"line_number":22,"context_line":""},{"line_number":23,"context_line":""},{"line_number":24,"context_line":"# Number of attempts to find a valid segment candidate and allocate it"},{"line_number":25,"context_line":"DB_MAX_ATTEMPTS \u003d 10"},{"line_number":26,"context_line":""},{"line_number":27,"context_line":""},{"line_number":28,"context_line":"LOG \u003d log.getLogger(__name__)"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a930d6b_0f85c0ac","line":25,"updated":"2015-01-22 15:23:28.000000000","message":"In current PS, DB_MAX_ATTEMPTS is useless","commit_id":"32d94887b4fdd1ba642bd86124b432f2cdca3951"},{"author":{"_account_id":6854,"name":"YAMAMOTO Takashi","email":"yamamoto@midokura.com","username":"yamamoto"},"change_message_id":"b9d5997567df3f9c086fb1ac535ba2a40e5e7c2c","unresolved":false,"context_lines":[{"line_number":131,"context_line":"                      {\"type\": network_type,"},{"line_number":132,"context_line":"                       \"segment\": raw_segment})"},{"line_number":133,"context_line":"            # saving real exception in case we exceeded amount of attempts"},{"line_number":134,"context_line":"            raise db_api.RetryRequestException("},{"line_number":135,"context_line":"                exc.NoNetworkFoundInMaximumAllowedAttempts())"}],"source_content_type":"text/x-python","patch_set":2,"id":"1a930d6b_658fc075","line":134,"updated":"2015-01-27 07:33:49.000000000","message":"RetryRequest vs RetryRequestException","commit_id":"6f73f5a8cf88db2e0ce7a7c856942e572335c34e"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"bc10f69ff4ac5401b6ba276ca9916a3cc1160fc4","unresolved":false,"context_lines":[{"line_number":131,"context_line":"                      {\"type\": network_type,"},{"line_number":132,"context_line":"                       \"segment\": raw_segment})"},{"line_number":133,"context_line":"            # saving real exception in case we exceeded amount of attempts"},{"line_number":134,"context_line":"            raise db_api.RetryRequestException("},{"line_number":135,"context_line":"                exc.NoNetworkFoundInMaximumAllowedAttempts())"}],"source_content_type":"text/x-python","patch_set":2,"id":"1a930d6b_d1d66d27","line":134,"in_reply_to":"1a930d6b_658fc075","updated":"2015-01-27 11:57:51.000000000","message":"sure, UTs have caught it","commit_id":"6f73f5a8cf88db2e0ce7a7c856942e572335c34e"},{"author":{"_account_id":4395,"name":"Aaron Rosen","email":"aaronorosen@gmail.com","username":"arosen"},"change_message_id":"d00d35b3a7025e24214c6c473fe3501488efbeb9","unresolved":false,"context_lines":[{"line_number":115,"context_line":"                      \"started with %(segment)s \","},{"line_number":116,"context_line":"                      {\"type\": network_type,"},{"line_number":117,"context_line":"                       \"segment\": raw_segment})"},{"line_number":118,"context_line":"            count \u003d (session.query(self.model)."},{"line_number":119,"context_line":"                     filter_by(allocated\u003dFalse, **raw_segment)."},{"line_number":120,"context_line":"                     update({\"allocated\": True}))"},{"line_number":121,"context_line":"            if count:"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_56cc756a","line":118,"updated":"2015-02-04 05:46:01.000000000","message":"nit: I Think we should call this error instead of count.","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"08b10b6eff1483d338f264e0e0ee6a754d27b579","unresolved":false,"context_lines":[{"line_number":115,"context_line":"                      \"started with %(segment)s \","},{"line_number":116,"context_line":"                      {\"type\": network_type,"},{"line_number":117,"context_line":"                       \"segment\": raw_segment})"},{"line_number":118,"context_line":"            count \u003d (session.query(self.model)."},{"line_number":119,"context_line":"                     filter_by(allocated\u003dFalse, **raw_segment)."},{"line_number":120,"context_line":"                     update({\"allocated\": True}))"},{"line_number":121,"context_line":"            if count:"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_6c01a637","line":118,"in_reply_to":"da86d52c_56cc756a","updated":"2015-02-04 07:40:09.000000000","message":"Done","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"64cbe4f936bc35473a373815eefcd61ccba68911","unresolved":false,"context_lines":[{"line_number":115,"context_line":"                      \"started with %(segment)s \","},{"line_number":116,"context_line":"                      {\"type\": network_type,"},{"line_number":117,"context_line":"                       \"segment\": raw_segment})"},{"line_number":118,"context_line":"            count \u003d (session.query(self.model)."},{"line_number":119,"context_line":"                     filter_by(allocated\u003dFalse, **raw_segment)."},{"line_number":120,"context_line":"                     update({\"allocated\": True}))"},{"line_number":121,"context_line":"            if count:"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_365c58ed","line":118,"in_reply_to":"da86d52c_6c01a637","updated":"2015-02-04 11:16:28.000000000","message":"On the second thought: this is exactly the original code, and plus, update method really returns number of updated rows, so I think the name of variable is fine.","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"c3d46826365daaec0ab9d7d02cb11156d10a1ebd","unresolved":false,"context_lines":[{"line_number":115,"context_line":"                      \"started with %(segment)s \","},{"line_number":116,"context_line":"                      {\"type\": network_type,"},{"line_number":117,"context_line":"                       \"segment\": raw_segment})"},{"line_number":118,"context_line":"            count \u003d (session.query(self.model)."},{"line_number":119,"context_line":"                     filter_by(allocated\u003dFalse, **raw_segment)."},{"line_number":120,"context_line":"                     update({\"allocated\": True}))"},{"line_number":121,"context_line":"            if count:"}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_4e0f2c37","line":118,"updated":"2015-02-05 19:31:29.000000000","message":"So, here, you will be using the same database session as previous executions of the retry loop. The:\n\n with session.begin(subtransactions\u003dTrue):\n\non line 101 will not create a branch new transaction and DB session. That\u0027s the main problem here I think. I\u0027m going to ask Mike Bayer to verify this, but I\u0027m pretty sure that line 101 will not result in a new database session...","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"e1e4acb666b2a3717be039fa61316feebdf1bae1","unresolved":false,"context_lines":[{"line_number":115,"context_line":"                      \"started with %(segment)s \","},{"line_number":116,"context_line":"                      {\"type\": network_type,"},{"line_number":117,"context_line":"                       \"segment\": raw_segment})"},{"line_number":118,"context_line":"            count \u003d (session.query(self.model)."},{"line_number":119,"context_line":"                     filter_by(allocated\u003dFalse, **raw_segment)."},{"line_number":120,"context_line":"                     update({\"allocated\": True}))"},{"line_number":121,"context_line":"            if count:"}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_9a95d034","line":118,"in_reply_to":"da86d52c_4e0f2c37","updated":"2015-02-06 06:42:52.000000000","message":"It  will because the method that is decorated had the outer-most transaction, which was rolled back due to RetryRequest exception.\nSo that outer-most method is restarted via the decorator, that gives brand new session.\n\nAlso, if you look at the patch depending on this one (multiple api_workers), here is a comment showing that this approach works as expected.","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"},{"author":{"_account_id":11816,"name":"mike bayer","display_name":"Mike Bayer","email":"mike_mp@zzzcomputing.com","username":"zzzeek","status":"Red Hat"},"change_message_id":"94b3e0819db6597793f32b179f9d59c7142fe5c6","unresolved":false,"context_lines":[{"line_number":115,"context_line":"                      \"started with %(segment)s \","},{"line_number":116,"context_line":"                      {\"type\": network_type,"},{"line_number":117,"context_line":"                       \"segment\": raw_segment})"},{"line_number":118,"context_line":"            count \u003d (session.query(self.model)."},{"line_number":119,"context_line":"                     filter_by(allocated\u003dFalse, **raw_segment)."},{"line_number":120,"context_line":"                     update({\"allocated\": True}))"},{"line_number":121,"context_line":"            if count:"}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_f13d2590","line":118,"in_reply_to":"da86d52c_4e0f2c37","updated":"2015-02-05 19:37:13.000000000","message":"this is correct.  only if you say session.begin(), without subtranscations\u003dTrue, can you be assured that the begin() call actually created a new transaction, which can only occur if the session is not already started within a transaction.\n\nin this case, since session is passed in, it seems very likely that there\u0027s already a transaction in progress.  to start a distinct transaction, you\u0027d use a totally different Session.\n\nit may seem inconvenient if the goal is to in fact share the objects from both transactions together, however there\u0027s a rationale here, which is that it isn\u0027t safe to just move a row from one session to another and assume its present in that transaction also (you can of course do this, but you have to be explicit about it).   my talk at http://www.sqlalchemy.org/library.html#thesqlalchemysessionindepth gets into this.","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"},{"author":{"_account_id":7,"name":"Jay Pipes","email":"jaypipes@gmail.com","username":"jaypipes"},"change_message_id":"6b56b35382b817605a5a3ae214bd71c825c286ca","unresolved":false,"context_lines":[{"line_number":115,"context_line":"                      \"started with %(segment)s \","},{"line_number":116,"context_line":"                      {\"type\": network_type,"},{"line_number":117,"context_line":"                       \"segment\": raw_segment})"},{"line_number":118,"context_line":"            count \u003d (session.query(self.model)."},{"line_number":119,"context_line":"                     filter_by(allocated\u003dFalse, **raw_segment)."},{"line_number":120,"context_line":"                     update({\"allocated\": True}))"},{"line_number":121,"context_line":"            if count:"}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_b40e1f39","line":118,"in_reply_to":"da86d52c_9a95d034","updated":"2015-02-06 14:03:12.000000000","message":"Hmm, I see your point now with regards to the exception triggering a ROLLBACK in the session.\n\nBut, something just doesn\u0027t feel right to me about this. ROLLBACKs should be for when things go wrong. In this case, nothing went wrong, per-se, it\u0027s just that another thread changed the record in between line 107 and line 120, causing the need to retry the read and write operation.\n\nPerhaps add a code comment below on line 133 that says something to the effect of this:\n\n # The exception raise here triggers a ROLLBACK of the session\n # which guarantees us that the retry mechanism will create a new\n # transaction/session in which to execute the SQL statements\n # above.","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"7bc8b80e47c27c8edc36016b22dc349c90c70029","unresolved":false,"context_lines":[{"line_number":115,"context_line":"                      \"started with %(segment)s \","},{"line_number":116,"context_line":"                      {\"type\": network_type,"},{"line_number":117,"context_line":"                       \"segment\": raw_segment})"},{"line_number":118,"context_line":"            count \u003d (session.query(self.model)."},{"line_number":119,"context_line":"                     filter_by(allocated\u003dFalse, **raw_segment)."},{"line_number":120,"context_line":"                     update({\"allocated\": True}))"},{"line_number":121,"context_line":"            if count:"}],"source_content_type":"text/x-python","patch_set":10,"id":"da86d52c_ea1b4c70","line":118,"in_reply_to":"da86d52c_b40e1f39","updated":"2015-02-06 17:12:50.000000000","message":"\u003e  ROLLBACKs should be for when things go wrong\nWell, not necessarily.\n\nIt\u0027s common case to do something like:\n\ndef create_depending_object(parent_id, params):\n    with session.begin(...):\n            if not session.query(Parent).filter_by(id\u003dparent_id).first():\n                 # at this point everything from DB perspective went ok,\n                 # we just decided that we can\u0027t proceed\n                 raise ParentNotFound() # that causes a rollback\n            # go on with creating an object\n\nSo I just think I\u0027m not don\u0027t anything special here.\nException thrown from \u0027with session.begin():\u0027 block always rollbacks the session","commit_id":"caedca67eb4a4c2366b6ebe7230ab31f69390eb2"}],"neutron/plugins/ml2/plugin.py":[{"author":{"_account_id":5803,"name":"Attila Fazekas","email":"afazekas@redhat.com","username":"afazekas"},"change_message_id":"eab0168cf49768463412880fd9610f195a0ebd7a","unresolved":false,"context_lines":[{"line_number":502,"context_line":"        items \u003d request_items[collection]"},{"line_number":503,"context_line":"        try:"},{"line_number":504,"context_line":"            with context.session.begin(subtransactions\u003dTrue):"},{"line_number":505,"context_line":"                obj_creator \u003d getattr(self, \u0027_create_%s_db\u0027 % resource)"},{"line_number":506,"context_line":"                for item in items:"},{"line_number":507,"context_line":"                    attrs \u003d item[resource]"},{"line_number":508,"context_line":"                    result, mech_context \u003d obj_creator(context, item)"}],"source_content_type":"text/x-python","patch_set":3,"id":"1a930d6b_068c30d9","line":505,"updated":"2015-01-27 16:19:37.000000000","message":"Inside a started transaction.","commit_id":"84569a3a879128b98bb39e22e0785408f85398b4"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"e8f71559aed825b57cc4f4e152554f6414f8314d","unresolved":false,"context_lines":[{"line_number":502,"context_line":"        items \u003d request_items[collection]"},{"line_number":503,"context_line":"        try:"},{"line_number":504,"context_line":"            with context.session.begin(subtransactions\u003dTrue):"},{"line_number":505,"context_line":"                obj_creator \u003d getattr(self, \u0027_create_%s_db\u0027 % resource)"},{"line_number":506,"context_line":"                for item in items:"},{"line_number":507,"context_line":"                    attrs \u003d item[resource]"},{"line_number":508,"context_line":"                    result, mech_context \u003d obj_creator(context, item)"}],"source_content_type":"text/x-python","patch_set":3,"id":"1a930d6b_ec70e3a5","line":505,"in_reply_to":"1a930d6b_068c30d9","updated":"2015-01-27 16:41:38.000000000","message":"for the bulk operation whole approach will not work. we need to consider removing outer transaction from it.","commit_id":"84569a3a879128b98bb39e22e0785408f85398b4"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"77b01764eb7d87e0df542b59da2aac1921339698","unresolved":false,"context_lines":[{"line_number":502,"context_line":"        items \u003d request_items[collection]"},{"line_number":503,"context_line":"        try:"},{"line_number":504,"context_line":"            with context.session.begin(subtransactions\u003dTrue):"},{"line_number":505,"context_line":"                obj_creator \u003d getattr(self, \u0027_create_%s_db\u0027 % resource)"},{"line_number":506,"context_line":"                for item in items:"},{"line_number":507,"context_line":"                    attrs \u003d item[resource]"},{"line_number":508,"context_line":"                    result, mech_context \u003d obj_creator(context, item)"}],"source_content_type":"text/x-python","patch_set":3,"id":"1a930d6b_4cfbb746","line":505,"in_reply_to":"1a930d6b_ec70e3a5","updated":"2015-01-27 16:54:22.000000000","message":"another consideration: current change doesn\u0027t make existing code worse, it will fail in exactly the same way it would fail previously.","commit_id":"84569a3a879128b98bb39e22e0785408f85398b4"},{"author":{"_account_id":5803,"name":"Attila Fazekas","email":"afazekas@redhat.com","username":"afazekas"},"change_message_id":"eab0168cf49768463412880fd9610f195a0ebd7a","unresolved":false,"context_lines":[{"line_number":534,"context_line":"                               \u0027resource_ids\u0027: \u0027, \u0027.join(resource_ids)})"},{"line_number":535,"context_line":"                self._delete_objects(context, resource, objects)"},{"line_number":536,"context_line":""},{"line_number":537,"context_line":"    @db_api.db_retry_on_request"},{"line_number":538,"context_line":"    def _create_network_db(self, context, network):"},{"line_number":539,"context_line":"        net_data \u003d network[attributes.NETWORK]"},{"line_number":540,"context_line":"        tenant_id \u003d self._get_tenant_id_for_create(context, net_data)"}],"source_content_type":"text/x-python","patch_set":3,"id":"1a930d6b_067a70bc","line":537,"updated":"2015-01-27 16:19:37.000000000","message":"You are just retrying a part of a transaction on bulk network create. It does not seams to work.","commit_id":"84569a3a879128b98bb39e22e0785408f85398b4"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"e8f71559aed825b57cc4f4e152554f6414f8314d","unresolved":false,"context_lines":[{"line_number":534,"context_line":"                               \u0027resource_ids\u0027: \u0027, \u0027.join(resource_ids)})"},{"line_number":535,"context_line":"                self._delete_objects(context, resource, objects)"},{"line_number":536,"context_line":""},{"line_number":537,"context_line":"    @db_api.db_retry_on_request"},{"line_number":538,"context_line":"    def _create_network_db(self, context, network):"},{"line_number":539,"context_line":"        net_data \u003d network[attributes.NETWORK]"},{"line_number":540,"context_line":"        tenant_id \u003d self._get_tenant_id_for_create(context, net_data)"}],"source_content_type":"text/x-python","patch_set":3,"id":"1a930d6b_2cad8be9","line":537,"in_reply_to":"1a930d6b_067a70bc","updated":"2015-01-27 16:41:38.000000000","message":"correct, but there\u0027s not much we can do with bulk creation.\nI doubt bulk creation should be atomic, see comment above.","commit_id":"84569a3a879128b98bb39e22e0785408f85398b4"},{"author":{"_account_id":5803,"name":"Attila Fazekas","email":"afazekas@redhat.com","username":"afazekas"},"change_message_id":"eab0168cf49768463412880fd9610f195a0ebd7a","unresolved":false,"context_lines":[{"line_number":539,"context_line":"        net_data \u003d network[attributes.NETWORK]"},{"line_number":540,"context_line":"        tenant_id \u003d self._get_tenant_id_for_create(context, net_data)"},{"line_number":541,"context_line":"        session \u003d context.session"},{"line_number":542,"context_line":"        with session.begin(subtransactions\u003dTrue):"},{"line_number":543,"context_line":"            self._ensure_default_security_group(context, tenant_id)"},{"line_number":544,"context_line":"            result \u003d super(Ml2Plugin, self).create_network(context, network)"},{"line_number":545,"context_line":"            self.extension_manager.process_create_network(session, net_data,"}],"source_content_type":"text/x-python","patch_set":3,"id":"1a930d6b_06619004","line":542,"updated":"2015-01-27 16:19:37.000000000","message":"substransaction\u003dTrue used.","commit_id":"84569a3a879128b98bb39e22e0785408f85398b4"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"dfb9de31b4794de417b7f5ec5a7c07b2e4bd8f10","unresolved":false,"context_lines":[{"line_number":534,"context_line":"                               \u0027resource_ids\u0027: \u0027, \u0027.join(resource_ids)})"},{"line_number":535,"context_line":"                self._delete_objects(context, resource, objects)"},{"line_number":536,"context_line":""},{"line_number":537,"context_line":"    @db_api.db_retry_on_request"},{"line_number":538,"context_line":"    def _create_network_db(self, context, network):"},{"line_number":539,"context_line":"        net_data \u003d network[attributes.NETWORK]"},{"line_number":540,"context_line":"        tenant_id \u003d self._get_tenant_id_for_create(context, net_data)"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_b18d0d7e","line":537,"updated":"2015-01-28 19:13:44.000000000","message":"I apologize if this was previously discussed, but why is this the appropriate scope for retry as opposed to higher?  Are there any general rules you would suggest for how this kind of decorator should be applied to the codebase?  Some documentation in devref is probably a good idea to make sure that this change\u0027s assumptions are properly communicated to a wider audience.","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"4fddf1f00d63321c2cad93c8ccc8d20abe4d7ff9","unresolved":false,"context_lines":[{"line_number":534,"context_line":"                               \u0027resource_ids\u0027: \u0027, \u0027.join(resource_ids)})"},{"line_number":535,"context_line":"                self._delete_objects(context, resource, objects)"},{"line_number":536,"context_line":""},{"line_number":537,"context_line":"    @db_api.db_retry_on_request"},{"line_number":538,"context_line":"    def _create_network_db(self, context, network):"},{"line_number":539,"context_line":"        net_data \u003d network[attributes.NETWORK]"},{"line_number":540,"context_line":"        tenant_id \u003d self._get_tenant_id_for_create(context, net_data)"}],"source_content_type":"text/x-python","patch_set":5,"id":"fa81d914_92de443e","line":537,"in_reply_to":"fa81d914_b18d0d7e","updated":"2015-01-28 21:09:32.000000000","message":"For this particular case the assumption is just to wrap the method having outer-most transaction that may have retrying logic inside.\n\nIt is a bit clumsy in the sense that code author needs to know that there could be retrying logic inside. It\u0027s not obvious on the level of invocation of this wrapper, so it requires some knowledge of the call graph.","commit_id":"768351444ae71daab62f59ec3a9170c9daba4455"},{"author":{"_account_id":6854,"name":"YAMAMOTO Takashi","email":"yamamoto@midokura.com","username":"yamamoto"},"change_message_id":"f628f0c9874198848d5ecf8308a06e7a75b05dec","unresolved":false,"context_lines":[{"line_number":536,"context_line":"                self._delete_objects(context, resource, objects)"},{"line_number":537,"context_line":""},{"line_number":538,"context_line":"    @db_api.db_retry_on_request"},{"line_number":539,"context_line":"    def _create_network_db(self, context, network):"},{"line_number":540,"context_line":"        net_data \u003d network[attributes.NETWORK]"},{"line_number":541,"context_line":"        tenant_id \u003d self._get_tenant_id_for_create(context, net_data)"},{"line_number":542,"context_line":"        session \u003d context.session"}],"source_content_type":"text/x-python","patch_set":7,"id":"da86d52c_2f81d28f","line":539,"updated":"2015-02-02 01:10:30.000000000","message":"as pointed out by afazekas in PS3, this method is used inside another transaction.\ndoesn\u0027t this make the existing code worse for pgsql?","commit_id":"ab2d974e4dd3ddb412edea2cf91124b23805bf94"},{"author":{"_account_id":5803,"name":"Attila Fazekas","email":"afazekas@redhat.com","username":"afazekas"},"change_message_id":"463e1cbe6a7418c9cbb4df973f98e85287bea3e7","unresolved":false,"context_lines":[{"line_number":503,"context_line":"        items \u003d request_items[collection]"},{"line_number":504,"context_line":"        try:"},{"line_number":505,"context_line":"            with context.session.begin(subtransactions\u003dTrue):"},{"line_number":506,"context_line":"                obj_creator \u003d getattr(self, \u0027_create_%s_db\u0027 % resource)"},{"line_number":507,"context_line":"                for item in items:"},{"line_number":508,"context_line":"                    attrs \u003d item[resource]"},{"line_number":509,"context_line":"                    result, mech_context \u003d obj_creator(context, item)"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_2a3836ee","line":506,"updated":"2015-02-05 13:01:44.000000000","message":"The Bulk creation still not handled.","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"56d9fa267652f674e9c1be3cde957f02b0c559b3","unresolved":false,"context_lines":[{"line_number":503,"context_line":"        items \u003d request_items[collection]"},{"line_number":504,"context_line":"        try:"},{"line_number":505,"context_line":"            with context.session.begin(subtransactions\u003dTrue):"},{"line_number":506,"context_line":"                obj_creator \u003d getattr(self, \u0027_create_%s_db\u0027 % resource)"},{"line_number":507,"context_line":"                for item in items:"},{"line_number":508,"context_line":"                    attrs \u003d item[resource]"},{"line_number":509,"context_line":"                    result, mech_context \u003d obj_creator(context, item)"}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_a06b671c","line":506,"in_reply_to":"da86d52c_2a3836ee","updated":"2015-02-05 13:53:08.000000000","message":"The bulk creation case is out of scope of this patch.\nAlso, proposed approach will not help much unless retry count is increased.\n\nI think it deserves separate research of how such concurrency issue could be resolved for bulk operations.","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":841,"name":"Akihiro Motoki","email":"amotoki@gmail.com","username":"amotoki"},"change_message_id":"f735488bd8153de2337e8dfa0194b66954e82962","unresolved":false,"context_lines":[{"line_number":554,"context_line":"            self.mechanism_manager.create_network_precommit(mech_context)"},{"line_number":555,"context_line":"        return result, mech_context"},{"line_number":556,"context_line":""},{"line_number":557,"context_line":"    @db_api.db_retry_on_request"},{"line_number":558,"context_line":"    def _create_network_with_retries(self, context, network):"},{"line_number":559,"context_line":"        return self._create_network_db(context, network)"},{"line_number":560,"context_line":""}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_adc8c055","line":557,"updated":"2015-02-05 13:17:31.000000000","message":"I understand we need to retry db request in the outermost transaction to avoid seeing the same content when retrying the request. However, it is better to mention the reason specific to ML2 plugin case in the commit message. The current commit message describes the general reason, but I believe describing Ml2 specific case helps us understand the reason in the future.","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"56d9fa267652f674e9c1be3cde957f02b0c559b3","unresolved":false,"context_lines":[{"line_number":554,"context_line":"            self.mechanism_manager.create_network_precommit(mech_context)"},{"line_number":555,"context_line":"        return result, mech_context"},{"line_number":556,"context_line":""},{"line_number":557,"context_line":"    @db_api.db_retry_on_request"},{"line_number":558,"context_line":"    def _create_network_with_retries(self, context, network):"},{"line_number":559,"context_line":"        return self._create_network_db(context, network)"},{"line_number":560,"context_line":""}],"source_content_type":"text/x-python","patch_set":9,"id":"da86d52c_e071df0c","line":557,"in_reply_to":"da86d52c_adc8c055","updated":"2015-02-05 13:53:08.000000000","message":"Done","commit_id":"3a874157a27ce2383f786f8b7d55cbea8f101db7"},{"author":{"_account_id":1689,"name":"Robert Kukura","email":"rk@theep.net","username":"rkukura"},"change_message_id":"117319dba211846694f6dc9cac2bfe4f88a0a6a4","unresolved":false,"context_lines":[{"line_number":607,"context_line":""},{"line_number":608,"context_line":"        return result"},{"line_number":609,"context_line":""},{"line_number":610,"context_line":"    def create_network_bulk(self, context, networks):"},{"line_number":611,"context_line":"        objects \u003d self._create_bulk_ml2(attributes.NETWORK, context, networks)"},{"line_number":612,"context_line":"        return [obj[\u0027result\u0027] for obj in objects]"},{"line_number":613,"context_line":""}],"source_content_type":"text/x-python","patch_set":11,"id":"da86d52c_6bf47e87","line":610,"updated":"2015-02-09 17:41:12.000000000","message":"Doesn\u0027t _create_bulk_ml2() also need to retry the transaction containing its calls to _create_network_db()? I see this was discussed on patch set 9, but I\u0027m not convinced that simply applying this approach won\u0027t help at least in some cases, and I don\u0027t see how it would do any harm.","commit_id":"f967d23e6cc506f67aea45c288cd5ea0b454698d"},{"author":{"_account_id":6072,"name":"Eugene Nikanorov","email":"enikanorov@mirantis.com","username":"enikanorov"},"change_message_id":"b85a1aac753c858fc0262fd04dea8ce9549104df","unresolved":false,"context_lines":[{"line_number":607,"context_line":""},{"line_number":608,"context_line":"        return result"},{"line_number":609,"context_line":""},{"line_number":610,"context_line":"    def create_network_bulk(self, context, networks):"},{"line_number":611,"context_line":"        objects \u003d self._create_bulk_ml2(attributes.NETWORK, context, networks)"},{"line_number":612,"context_line":"        return [obj[\u0027result\u0027] for obj in objects]"},{"line_number":613,"context_line":""}],"source_content_type":"text/x-python","patch_set":11,"id":"da86d52c_bd20729c","line":610,"in_reply_to":"da86d52c_6bf47e87","updated":"2015-02-09 20:15:09.000000000","message":"I\u0027d really like to avoid modifying bulk-creation logic and related testing efforts.\n\nI don\u0027t think that existing API contract for bulk operations is right way to do, and that\u0027s why I\u0027d prefer not to modify it.","commit_id":"f967d23e6cc506f67aea45c288cd5ea0b454698d"}]}
