)]}'
{"keystone/identity/backends/sql.py":[{"author":{"_account_id":11816,"name":"mike_mp@zzzcomputing.com","display_name":"Mike Bayer","email":"mike_mp@zzzcomputing.com","username":"zzzeek","status":"Red Hat"},"change_message_id":"b4b5a9b2870dc8f5169a2946b16929196f9b849f","unresolved":false,"context_lines":[{"line_number":188,"context_line":"        if for_update:"},{"line_number":189,"context_line":"            user_ref \u003d session.query("},{"line_number":190,"context_line":"                model.User).with_for_update("},{"line_number":191,"context_line":"                    nowait\u003dTrue, of\u003dmodel.User).get(user_id)"},{"line_number":192,"context_line":"        else:"},{"line_number":193,"context_line":"            user_ref \u003d session.query(model.User).get(user_id)"},{"line_number":194,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"bf51134e_6f71b244","line":191,"updated":"2020-07-09 01:53:07.000000000","message":"I\u0027m not sure that this makes anything worse, but at least on Galera, SELECT FOR UPDATE does not actually lock across masters, it instead will fail one of the writers if there are competing writes on two masters.  Assuming the \"handle_conflicts\" decorator will retry for \"Deadlock found when trying to get lock\", it will still be OK.   you\u0027ve probably seen this but http://www.joinfu.com/2015/01/understanding-reservations-concurrency-locking-in-nova/ is the classic openstack blog post on this topic.\n\nthat this also specifies NOWAIT, I guess this is already the intention, to fail fast into the retry decorator if there is competition for the row.\n\nbut then the commit message refers to the 500 server error due to stale data.   So, if you\u0027re looking for this to gracefully block other requests so that nothing raises, that\u0027s not what this will do.   I\u0027m not really sure what the relationship is between the 500 server errors you mention and the purpose of \"@sql.handle_conflicts\".\n\nRe: \"OF\", in the MySQL world this is only supported by MySQL 8, and not at all by MariaDB.  If this SELECT statement is only against the \"user\" table then I don\u0027t think OF makes any difference, it\u0027s used to indicate which of multiple tables in the statement should have the lock.","commit_id":"12b7291e53aff9e5acf367fefccb3af17df31042"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"ffe9e467e96b5a23127a59023ed54ff9fa01ef46","unresolved":false,"context_lines":[{"line_number":188,"context_line":"        if for_update:"},{"line_number":189,"context_line":"            user_ref \u003d session.query("},{"line_number":190,"context_line":"                model.User).with_for_update("},{"line_number":191,"context_line":"                    nowait\u003dTrue, of\u003dmodel.User).get(user_id)"},{"line_number":192,"context_line":"        else:"},{"line_number":193,"context_line":"            user_ref \u003d session.query(model.User).get(user_id)"},{"line_number":194,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"9f560f44_37daf81c","line":191,"in_reply_to":"bf51134e_6f71b244","updated":"2020-08-27 21:20:58.000000000","message":"Thanks for the context, Mike.\n\nI\u0027m updating the approach to try @wrap_db_retry()","commit_id":"12b7291e53aff9e5acf367fefccb3af17df31042"},{"author":{"_account_id":11816,"name":"mike_mp@zzzcomputing.com","display_name":"Mike Bayer","email":"mike_mp@zzzcomputing.com","username":"zzzeek","status":"Red Hat"},"change_message_id":"89c938c655e6885e0892f299dd584ef3b4aad035","unresolved":false,"context_lines":[{"line_number":210,"context_line":"    @sql.handle_conflicts(conflict_type\u003d\u0027user\u0027)"},{"line_number":211,"context_line":"    @oslo_db_api.wrap_db_retry(retry_on_deadlock\u003dTrue)"},{"line_number":212,"context_line":"    def update_user(self, user_id, user):"},{"line_number":213,"context_line":"        with sql.session_for_write() as session:"},{"line_number":214,"context_line":"            user_ref \u003d self._get_user(session, user_id)"},{"line_number":215,"context_line":"            old_user_dict \u003d user_ref.to_dict()"},{"line_number":216,"context_line":"            for k in user:"}],"source_content_type":"text/x-python","patch_set":3,"id":"9f560f44_81c2d432","line":213,"updated":"2020-09-10 13:39:38.000000000","message":"does session_for_write() call session.commit() at the end of the block?","commit_id":"c839f3e235b44868dc7b12f91549a81b67d80131"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"9422e91589b741b51b17b491b6e55cadac25d1bb","unresolved":false,"context_lines":[{"line_number":210,"context_line":"    @sql.handle_conflicts(conflict_type\u003d\u0027user\u0027)"},{"line_number":211,"context_line":"    @oslo_db_api.wrap_db_retry(retry_on_deadlock\u003dTrue)"},{"line_number":212,"context_line":"    def update_user(self, user_id, user):"},{"line_number":213,"context_line":"        with sql.session_for_write() as session:"},{"line_number":214,"context_line":"            user_ref \u003d self._get_user(session, user_id)"},{"line_number":215,"context_line":"            old_user_dict \u003d user_ref.to_dict()"},{"line_number":216,"context_line":"            for k in user:"}],"source_content_type":"text/x-python","patch_set":3,"id":"3f65232a_c9567707","line":213,"in_reply_to":"3f65232a_06b17c90","updated":"2020-10-21 20:48:38.000000000","message":"Actually - my previous comment was just the connection/session factory, which returns one of these [0].\n\nI think it attempts to commit changes here [1][2], which should be when the context manager is cleaned up?\n\nDoes that help?\n\n[0] https://opendev.org/openstack/oslo.db/src/branch/master/oslo_db/sqlalchemy/enginefacade.py#L584\n[1] https://opendev.org/openstack/oslo.db/src/branch/master/oslo_db/sqlalchemy/enginefacade.py#L663\n[2] https://opendev.org/openstack/oslo.db/src/branch/master/oslo_db/sqlalchemy/enginefacade.py#L691","commit_id":"c839f3e235b44868dc7b12f91549a81b67d80131"},{"author":{"_account_id":11816,"name":"mike_mp@zzzcomputing.com","display_name":"Mike Bayer","email":"mike_mp@zzzcomputing.com","username":"zzzeek","status":"Red Hat"},"change_message_id":"d0406e90aebf043287c095d10a14912ff957866b","unresolved":false,"context_lines":[{"line_number":210,"context_line":"    @sql.handle_conflicts(conflict_type\u003d\u0027user\u0027)"},{"line_number":211,"context_line":"    @oslo_db_api.wrap_db_retry(retry_on_deadlock\u003dTrue)"},{"line_number":212,"context_line":"    def update_user(self, user_id, user):"},{"line_number":213,"context_line":"        with sql.session_for_write() as session:"},{"line_number":214,"context_line":"            user_ref \u003d self._get_user(session, user_id)"},{"line_number":215,"context_line":"            old_user_dict \u003d user_ref.to_dict()"},{"line_number":216,"context_line":"            for k in user:"}],"source_content_type":"text/x-python","patch_set":3,"id":"3f65232a_e95b7351","line":213,"in_reply_to":"3f65232a_c9567707","updated":"2020-10-21 21:59:45.000000000","message":"yeah this is the writer block so should be committing.","commit_id":"c839f3e235b44868dc7b12f91549a81b67d80131"},{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"a2a306f72828e467416c57432050b3d950506657","unresolved":false,"context_lines":[{"line_number":210,"context_line":"    @sql.handle_conflicts(conflict_type\u003d\u0027user\u0027)"},{"line_number":211,"context_line":"    @oslo_db_api.wrap_db_retry(retry_on_deadlock\u003dTrue)"},{"line_number":212,"context_line":"    def update_user(self, user_id, user):"},{"line_number":213,"context_line":"        with sql.session_for_write() as session:"},{"line_number":214,"context_line":"            user_ref \u003d self._get_user(session, user_id)"},{"line_number":215,"context_line":"            old_user_dict \u003d user_ref.to_dict()"},{"line_number":216,"context_line":"            for k in user:"}],"source_content_type":"text/x-python","patch_set":3,"id":"3f65232a_06b17c90","line":213,"in_reply_to":"9f560f44_81c2d432","updated":"2020-10-21 20:28:14.000000000","message":"I\u0027m not entirely sure. That method returns an instance of  _TransactionContextManager from oslo.db.\n\nhttps://opendev.org/openstack/oslo.db/src/branch/master/oslo_db/sqlalchemy/enginefacade.py#L752\n\nShould we not be using that?\n\nAlso, I patched this into an environment and test it manually, but it doesn\u0027t appear to fix the issue.","commit_id":"c839f3e235b44868dc7b12f91549a81b67d80131"}],"keystone/tests/unit/test_backend_sql.py":[{"author":{"_account_id":5046,"name":"Lance Bragstad","email":"lbragstad@redhat.com","username":"ldbragst"},"change_message_id":"1413beebc82974b146488fe250e2a9c4425d8916","unresolved":true,"context_lines":[{"line_number":1005,"context_line":"            session,"},{"line_number":1006,"context_line":"            session"},{"line_number":1007,"context_line":"        ]"},{"line_number":1008,"context_line":"        sql.session_for_write \u003d mock.Mock(side_effect\u003dside_effects)"},{"line_number":1009,"context_line":""},{"line_number":1010,"context_line":"        # Update a user\u0027s attribute, the first attempt will fail but oslo.db"},{"line_number":1011,"context_line":"        # will handle the exception and retry, the second attempt will succeed"}],"source_content_type":"text/x-python","patch_set":7,"id":"6c627af8_6250767e","line":1008,"updated":"2021-03-26 19:39:54.000000000","message":"This mock is apparently bleeding across tests...","commit_id":"6b581bfe43811379e9ceea2770242f05f0c9fa66"}]}
