diff options
| author | Zuul <zuul@review.opendev.org> | 2021-10-01 03:05:24 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2021-10-01 03:05:24 +0000 |
| commit | 36e65cc4ca674d61f2dde6b16e310886fcf10a06 (patch) | |
| tree | d8ae8515c30ef55cb0ac8e6942f43b92d7aea661 /keystone/identity/backends/sql.py | |
| parent | 03b4e3975abdeb50dea6b1b426dcdaa1a2d9eeb6 (diff) | |
| parent | ebc3f805f275a267e58e8251757a8dbb211153a0 (diff) | |
| download | keystone-queens-eol.tar.gz | |
Merge "Retry update_user when sqlalchemy raises StaleDataErrors" into stable/queensqueens-eol
Diffstat (limited to 'keystone/identity/backends/sql.py')
| -rw-r--r-- | keystone/identity/backends/sql.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/keystone/identity/backends/sql.py b/keystone/identity/backends/sql.py index ae23ebad7..ee4d4bbf9 100644 --- a/keystone/identity/backends/sql.py +++ b/keystone/identity/backends/sql.py @@ -32,6 +32,10 @@ from keystone.identity.backends import sql_model as model CONF = keystone.conf.CONF +def _stale_data_exception_checker(exc): + return isinstance(exc, sqlalchemy.orm.exc.StaleDataError) + + class Identity(base.IdentityDriverBase): # NOTE(henry-nash): Override the __init__() method so as to take a # config parameter to enable sql to be used as a domain-specific driver. @@ -201,6 +205,10 @@ class Identity(base.IdentityDriverBase): return base.filter_user(user_ref.to_dict()) @sql.handle_conflicts(conflict_type='user') + # Explicitly retry on StaleDataErrors, which can happen if two clients + # update the same user's password and the second client has stale password + # information. + @oslo_db_api.wrap_db_retry(exception_checker=_stale_data_exception_checker) def update_user(self, user_id, user): with sql.session_for_write() as session: user_ref = self._get_user(session, user_id) |
