(no title)
akrauss | 1 year ago
When objects and relations change in the applications database, then these changes will often have to be reflected in the permissions database as well, and the application must keep things in sync. But this is probably harder as it first seems, in the presence of errors and transaction rollbacks.
What about this case:
- User creates a FOO in the application.
- The app creates an entry in the "foo" table and assigns the user id as owner, and attempts to store various other data.
- The app also creates an entity in the permissions database and assigns the user id as an owner.
- Then further steps are performed, and one of them fails, rolling back the transaction in the application database.
I would assume that the change to the permissions database cannot be rolled back then, so there is now an inconsistency.
What do people typically do about these things?
EgeAytin|1 year ago
If the transaction fails, you should delete the malformed relation tuple from Permify to maintain consistency.
Here's an example of how this might look in code:
```
func CreateDocuments(db *gorm.DB) error {
}```
Although this is an anti-pattern, this approach ensures that if the transaction in the application database fails and is rolled back, the corresponding data in Permify is also deleted, preventing inconsistencies.
akrauss|1 year ago
If yes, then this is quite a burden and might be a valid reason for not using a separate permissions store. But maybe there are better ways...?
rzzzt|1 year ago
XA is such a standard that pops up often when data sources support such a mechanism:
- https://en.wikipedia.org/wiki/X/Open_XA
- https://dev.mysql.com/doc/refman/8.0/en/xa.html
- https://mariadb.com/kb/en/xa-transactions/
akrauss|1 year ago