Assign/Unassign roles in transaction

Hello,

Unless I am mistaken, the transaction API does not support user role assignment operations.
Therefore I’m wondering how can I do to ensure consistency between my DB data and user roles?

Thank you.

1 Like

Hi @Seb777 ,

Transaction API ensures consistency only of data in the tables of Data Service. In your case you should implement your client logic in a way in which it will be able to handle situations when during roles assignment error is occurred.

Regards, Andriy

Hi @Andriy_Konoz

I guess I can do something like this:

  • Creation of transaction A.
  • Add operation A1
  • Add operation A2
  • Execution of transaction A
  • If transaction A is successful, add user role
  • If exception when assigning the role, creation of a new transaction B for rollback transaction A.

But what if transaction B throws an exception?

I will do my best but I think there will always be a risk of inconsistency.

Hi @Seb777 ,

If transaction B ends with exception then an application can retry it at least one more time and if it still ends with error - report the error to its developer. Unfortunately there is no other way. If you use Java for server code you can try to use Failsafe library to simplify handling of such situations.

Regards, Andriy

Ok I will take a look at Failsafe.

Thank you @Andriy_Konoz !