zachliu commented on issue #23512:
URL: https://github.com/apache/airflow/issues/23512#issuecomment-1120127422
further investigation shows that we are removing the same "permissions" and
"permission views" repeatedly and trying to add them back repeatedly:
```
webserver_1 | [2022-05-07 02:50:25 +0000] [107] [INFO] Using worker: sync
webserver_1 | [2022-05-07 02:50:25 +0000] [117] [INFO] Booting worker with
pid: 117
webserver_1 | [2022-05-07 02:50:25 +0000] [118] [INFO] Booting worker with
pid: 118
webserver_1 | [2022-05-07 02:50:25 +0000] [119] [INFO] Booting worker with
pid: 119
webserver_1 | [2022-05-07 02:50:25 +0000] [120] [INFO] Booting worker with
pid: 120
webserver_1 | [2022-05-07 02:50:25,341] {{logging_config.py:46}} INFO -
Successfully imported user-defined logging config from log_config.LOGGING_CONFIG
webserver_1 | [2022-05-07 02:50:25,400] {{logging_config.py:46}} INFO -
Successfully imported user-defined logging config from log_config.LOGGING_CONFIG
webserver_1 | [2022-05-07 02:50:25,532] {{logging_config.py:46}} INFO -
Successfully imported user-defined logging config from log_config.LOGGING_CONFIG
webserver_1 | [2022-05-07 02:50:25,600] {{logging_config.py:46}} INFO -
Successfully imported user-defined logging config from log_config.LOGGING_CONFIG
webserver_1 | [2022-05-07 02:50:25,692] {{manager.py:585}} INFO - Removed
Permission can create on Users to role Admin
webserver_1 | [2022-05-07 02:50:25,705] {{manager.py:585}} INFO - Removed
Permission can create on Users to role Admin
webserver_1 | [2022-05-07 02:50:25,724] {{manager.py:543}} INFO - Removed
Permission View: can_create on Users
webserver_1 |
/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py:1461
SAWarning: DELETE statement on table 'ab_permission_view' expected to delete 1
row(s); 0 were matched. Please set confirm_deleted_rows=False within the
mapper configuration to prevent this warning.
webserver_1 | [2022-05-07 02:50:25,736] {{manager.py:543}} INFO - Removed
Permission View: can_create on Users
webserver_1 | [2022-05-07 02:50:25,912] {{manager.py:585}} INFO - Removed
Permission menu access on Permissions to role Admin
webserver_1 | [2022-05-07 02:50:25,912] {{manager.py:585}} INFO - Removed
Permission menu access on Permissions to role Admin
webserver_1 | [2022-05-07 02:50:25,923] {{manager.py:543}} INFO - Removed
Permission View: menu_access on Permissions
webserver_1 |
/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/persistence.py:1461
SAWarning: DELETE statement on table 'ab_permission_view' expected to delete 1
row(s); 0 were matched. Please set confirm_deleted_rows=False within the
mapper configuration to prevent this warning.
webserver_1 | [2022-05-07 02:50:25,935] {{manager.py:543}} INFO - Removed
Permission View: menu_access on Permissions
webserver_1 | [2022-05-07 02:50:26,016] {{manager.py:508}} INFO - Created
Permission View: menu access on Permissions
webserver_1 | [2022-05-07 02:50:26,027] {{manager.py:568}} INFO - Added
Permission menu access on Permissions to role Admin
webserver_1 | [2022-05-07 02:50:26,067] {{manager.py:585}} INFO - Removed
Permission menu access on Permissions to role Admin
webserver_1 | [2022-05-07 02:50:26,091] {{manager.py:543}} INFO - Removed
Permission View: menu_access on Permissions
postgres_1 | 2022-05-07 02:50:26.093 UTC [43] ERROR: insert or update on
table "ab_permission_view_role" violates foreign key constraint
"ab_permission_view_role_permission_view_id_fkey"
postgres_1 | 2022-05-07 02:50:26.093 UTC [43] DETAIL: Key
(permission_view_id)=(220) is not present in table "ab_permission_view".
postgres_1 | 2022-05-07 02:50:26.093 UTC [43] STATEMENT: INSERT INTO
ab_permission_view_role (id, permission_view_id, role_id) VALUES
(nextval('ab_permission_view_role_id_seq'), 220, 1) RETURNING
ab_permission_view_role.id
webserver_1 | [2022-05-07 02:50:26,096] {{manager.py:570}} ERROR - Add
Permission to Role Error: (psycopg2.errors.ForeignKeyViolation) insert or
update on table "ab_permission_view_role" violates foreign key constraint
"ab_permission_view_role_permission_view_id_fkey"
webserver_1 | DETAIL: Key (permission_view_id)=(220) is not present in
table "ab_permission_view".
webserver_1 |
webserver_1 | [SQL: INSERT INTO ab_permission_view_role (id,
permission_view_id, role_id) VALUES (nextval('ab_permission_view_role_id_seq'),
%(permission_view_id)s, %(role_id)s) RETURNING ab_permission_view_role.id]
webserver_1 | [parameters: {'permission_view_id': 220, 'role_id': 1}]
webserver_1 | (Background on this error at: http://sqlalche.me/e/14/gkpj)
```
notice the 2 `SAWarning: ...` when we tried to `Removed Permission View:
can_create on Users`. Apparently the same `DELETE` was executed twice.
I don't understand why we `Removed Permission menu access on Permissions
from role Admin` and then immediately `Added Permission menu access on
Permissions to role Admin` (the same with `can create on Users` permission)
:thinking:
The database screenshots which shows the permissions and permission views
are being deleted and added back hence their IDs are increasing


--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]