Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit Model commit (sparql update) handling #194

Open
dlamoris opened this issue Feb 10, 2025 · 0 comments
Open

Revisit Model commit (sparql update) handling #194

dlamoris opened this issue Feb 10, 2025 · 0 comments

Comments

@dlamoris
Copy link
Contributor

dlamoris commented Feb 10, 2025

This is model update part of #150, goal is to simplify transaction/race conditions handling and fully support multiple operations in a sparql update (except graph specific updates)

Proposed flow:

  1. 'lock' the branch in the triplestore - there's already a transaction object that gets added, can further use that:
insert {
	transaction on branch
} where {
	not exist {
		other transaction on branch
	}
}

in addition can do auth etc check here
2. wrap the rest in a try catch to delete the transaction if any exception occurs
3. transaction added check, select staging graph, if txn doesn't exist return 409 (this can be similar to the check done by model query)
4. process user update - maintain update string

for each operation in the update:
	- exception if user specified graph, or unsupported operation
	- insert data, delete data, delete where - surround block with staging graph (WITH can't be used here?)
	- insert delete where - add WITH staging graph at the beginning
 - at the end add one more operation that inserts some transaction annotation that user update succeeded, can also do commit/branch metadata update here
  • this would support any number of operations in one update, don't have to worry about variable clashing in trying to combine them
  • should still be compatible with the commit patch string using ?__mms_model substitution in the update string for staging graph, minus the transaction/metadata operation
  1. Query to check update succeeded, otherwise failed
  2. remove transaction and return commit
  3. do the stuff after an update (copy and make model graph)

Using the triplestore for the 'lock' have some risks if the server somehow crashed without cleaning up a transaction (would require a manual cleanup), but this would still work if layer1 is clustered.
Alternative is some kind of mutex in the code but would need to be a mutex per branch, would not work in a clustered deployment without some further considerations

@dlamoris dlamoris added this to Flexo Feb 10, 2025
@github-project-automation github-project-automation bot moved this to New in Flexo Feb 10, 2025
@dlamoris dlamoris moved this from New to In Progress in Flexo Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

1 participant