Clarification / Implementation: Conflict Resolution, Transactions, and Batch Writes #13348
Labels
AppSync
Related to AppSync issues
documentation
Related to documentation feature requests
Feedback
Feedback on our library
GraphQL
Related to GraphQL API issues
Service Team
Issues asked to the Service Team
Is this related to a new or existing framework?
No response
Is this related to a new or existing API?
REST API, GraphQL API, DataStore
Is this related to another service?
appsync, dynamodb
Describe the feature you'd like to request
There doesn't seem to be any direct documentation listing the lack of support for transactions and batch writes when conflict resolution is enabled. I have attempted to write resolvers for each and I end up getting these errors:
An unfortunate circumstance to spend hours researching and implementing just to dead end on an error. I suggest the docs be made more clear on this issue.
I searched the docs for hours. The most relevant articles, that I feel should contain this info, are here:
conflict detection and sync
https://docs.aws.amazon.com/appsync/latest/devguide/conflict-detection-and-sync.html
transactions
https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-dynamodb-transact.html
batch writes
https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-dynamodb-batch.html
Describe the solution you'd like
Two conclusions
Why post here:
There doesn't seem to be a great community for AppSync. I've found a repo here, but it seems fairly inactive. AppSync its self isn't open source, so I understand. Also, most people (like myself) seem to come to AppSync by way of Amplify. Writing resolvers for Amplify requires reading the AppSync documentation anyway, so this seems the most appropriate place for the issue.
Bonus Points!!!
Why are TransactWriteItems and BatchGetItem unsupported with Conflict Resolution? My experience implementing many databases has been - that for real world, commercial apps, concurrency requires both:
I really don't know any other way to get a highly concurrent app. Transactions unfortunately slow down the app, but there are inevitable use cases, (usually for internal users), that always require a consistent multi item write. Since TransactWriteItems exists clearly locks can be set on a DynamoDB resource.
Describe alternatives you've considered
Only two solutions I can see:
My go to solution when a multi-item write is required is:
a. re-fetch any stale data when ttl expires
b. throw out any writes with old row versions and notify client of error so they can re-fetch and try again.
I'm going to make the bold claim that this is the only way to get air tight concurrency. There are lots of ways to implement, but this strategy is sort of a must, because otherwise you can be trying to deconflict a data set where several partial writes by several clients have happened, resulting in you data being in a "broken state". Good luck deconflicting that to everyone's satisfaction!!
To implement a conflict resolution feature all you need is a table you can write to.
It's all done by adding metadata fields to data and processing them client side.
To implement a transaction isolation feature, you need control of locks.
AppSync only gives control of locks as transactions. Turned off by Conflict Resolution.
AppSync's pre-existing conflict resolution is a really, really good implementation. A shame that we are just forbidden access to resource locks.
Additional context
No response
Is this something that you'd be interested in working on?
The text was updated successfully, but these errors were encountered: