Delete user doesn't delete user-tenant

Create user, add to tenant. Delete user. Recreate user (same data) and the following error occurs:

This occurs both when creating the user in the REST API and through the web interface.

Camunda 7.8.0.

Failed :
Creating tenant memberships failed: ENGINE-03083 Exception while executing Batch Database Operations with message ' ### Error flushing statements. Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity.insertAuthorization (batch index #1) failed. Cause: org.h2.jdbc.JdbcBatchUpdateException: Unique index or primary key violation: "ACT_UNIQ_AUTH_USER_INDEX_6 ON PUBLIC.ACT_RU_AUTHORIZATION(TYPE_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_) VALUES (1, 'patrick', 11, 'BancoBig', 64)"; SQL statement: insert into ACT_RU_AUTHORIZATION ( ID_, TYPE_, GROUP_ID_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_, PERMS_, REV_ ) values ( ?, ?, ?, ?, ?, ?, ?, 1 ) [23505-190] ### Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity.insertAuthorization (batch index #1) failed. Cause: org.h2.jdbc.JdbcBatchUpdateException: Unique index or primary key violation: "ACT_UNIQ_AUTH_USER_INDEX_6 ON PUBLIC.ACT_RU_AUTHORIZATION(TYPE_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_) VALUES (1, 'patrick', 11, 'BancoBig', 64)"; SQL statement: insert into ACT_RU_AUTHORIZATION ( ID_, TYPE_, GROUP_ID_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_, PERMS_, REV_ ) values ( ?, ?, ?, ?, ?, ?, ?, 1 ) [23505-190] org.h2.jdbc.JdbcBatchUpdateException: Unique index or primary key violation: "ACT_UNIQ_AUTH_USER_INDEX_6 ON PUBLIC.ACT_RU_AUTHORIZATION(TYPE_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_) VALUES (1, 'patrick', 11, 'BancoBig', 64)"; SQL statement: insert into ACT_RU_AUTHORIZATION ( ID_, TYPE_, GROUP_ID_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_, PERMS_, REV_ ) values ( ?, ?, ?, ?, ?, ?, ?, 1 ) [23505-190] org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "ACT_UNIQ_AUTH_USER_INDEX_6 ON PUBLIC.ACT_RU_AUTHORIZATION(TYPE_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_) VALUES (1, 'patrick', 11, 'BancoBig', 64)"; SQL statement: insert into ACT_RU_AUTHORIZATION ( ID_, TYPE_, GROUP_ID_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_, PERMS_, REV_ ) values ( ?, ?, ?, ?, ?, ?, ?, 1 ) [23505-190] '. Flush summary: [ INSERT AuthorizationEntity[bba4790e-4c46-11e8-aa54-ea0072df18d8] INSERT TenantMembershipEntity[bba451fd-4c46-11e8-aa54-ea0072df18d8] ]

Hi @pn-ms,

I tried it and it is working for me (7.8 & 7.9). Could verify that you deleted successfully the user via rest request before trying the recreated it again.

Best regards,
Yana

Yana,

I just tested with new download of 7.8.0 and 7.9.0-alpha4:

Unzip, start Camunda
Log in as demo/demo
Create two new tenants <- never tried with one tenant
Create new user
Add user to a tenant
Check via rest /engine-rest/user returns 5 users
Stop Camunda
Restart Camunda
Open user list (web)
Select newest user
Select account
Delete user
Check via rest /engine-rest/user returns 4 users
Stop Camunda
Restart Camunda
Open user list (web)
Add new user (same data)
Check via rest /engine-rest/user returns 5 users
Add user to same tenant
Error

This occurs in both 7.8 and 7.9.0-alpha4.

Error data below (from modal dialog in web):

Failed :
Creating tenant memberships failed: ENGINE-03083 Exception while executing Batch Database Operations with message ’ ### Error flushing statements. Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity.insertAuthorization (batch index #1) failed. Cause: org.h2.jdbc.JdbcBatchUpdateException: Unique index or primary key violation: “ACT_UNIQ_AUTH_USER_INDEX_6 ON PUBLIC.ACT_RU_AUTHORIZATION(TYPE_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_) VALUES (1, ‘patrick’, 11, ‘BancoBig’, 62)”; SQL statement: insert into ACT_RU_AUTHORIZATION ( ID_, TYPE_, GROUP_ID_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_, PERMS_, REV_ ) values ( ?, ?, ?, ?, ?, ?, ?, 1 ) [23505-190] ### Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity.insertAuthorization (batch index #1) failed. Cause: org.h2.jdbc.JdbcBatchUpdateException: Unique index or primary key violation: “ACT_UNIQ_AUTH_USER_INDEX_6 ON PUBLIC.ACT_RU_AUTHORIZATION(TYPE_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_) VALUES (1, ‘patrick’, 11, ‘BancoBig’, 62)”; SQL statement: insert into ACT_RU_AUTHORIZATION ( ID_, TYPE_, GROUP_ID_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_, PERMS_, REV_ ) values ( ?, ?, ?, ?, ?, ?, ?, 1 ) [23505-190] org.h2.jdbc.JdbcBatchUpdateException: Unique index or primary key violation: “ACT_UNIQ_AUTH_USER_INDEX_6 ON PUBLIC.ACT_RU_AUTHORIZATION(TYPE_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_) VALUES (1, ‘patrick’, 11, ‘BancoBig’, 62)”; SQL statement: insert into ACT_RU_AUTHORIZATION ( ID_, TYPE_, GROUP_ID_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_, PERMS_, REV_ ) values ( ?, ?, ?, ?, ?, ?, ?, 1 ) [23505-190] org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: “ACT_UNIQ_AUTH_USER_INDEX_6 ON PUBLIC.ACT_RU_AUTHORIZATION(TYPE_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_) VALUES (1, ‘patrick’, 11, ‘BancoBig’, 62)”; SQL statement: insert into ACT_RU_AUTHORIZATION ( ID_, TYPE_, GROUP_ID_, USER_ID_, RESOURCE_TYPE_, RESOURCE_ID_, PERMS_, REV_ ) values ( ?, ?, ?, ?, ?, ?, ?, 1 ) [23505-190] '. Flush summary: [ INSERT AuthorizationEntity[697dd8ed-4dd8-11e8-ba1d-ae5c81394355] INSERT TenantMembershipEntity[697dd8ec-4dd8-11e8-ba1d-ae5c81394355] ]

Hi @pn-ms,

Sorry for the delay.
I was able to reproduce the issue. I will return to you later when I have more insights regarding the issue.

Best regards,
Yana

1 Like

Hi @pn-ms,

I created a bug report (CAM-9074) regarding this.

The root cause is that the tenant authorization has not been deleted.
You can verify that if you go to Admin -> Authorizations -> Tenant
and check if the tenant authorizations for patrick user are still there.

As a workaround you can delete this authorization manually.

Do you have interest in providing a fix as a pull request?

Best regards,
Yana

1 Like

CAM-9074 has been resolved and the fix will be shipped with 7.9.0 and 7.8.7 versions.
Thanks for reporting this.

1 Like