Question about SNAPSHOT isolation level

Hi,

I have a question about SNAPSHOT isolation level.

I’m trying to “update” an object.

So I run a query to delete every statement for a subject and insert the new statements. Like this:

delete {graph ?g {?a ?b ?c}}
insert {graph ?g {
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://data.einnsyn.no/brukermeta/Sluttbruker> .
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://data.einnsyn.no/brukermeta/passordExpiry> "2018-03-09T11:33:51.000+01:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://data.einnsyn.no/brukermeta/active> "false"^^<http://www.w3.org/2001/XMLSchema#boolean> .
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://data.einnsyn.no/brukermeta/oppdatertDato> "2017-12-09T11:33:52.136+01:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://data.einnsyn.no/brukermeta/fornavn> "1090766619" .
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://data.einnsyn.no/brukermeta/opprettetDato> "2017-12-09T11:33:51.520+01:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://data.einnsyn.no/brukermeta/organisasjon> "-406465849" .
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <tag:complexible:pinto:brukerType> "http://data.einnsyn.no/brukermeta/Sluttbruker" .
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://data.einnsyn.no/brukermeta/brukernavn> "a" .
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://data.einnsyn.no/brukermeta/loginFoersoek> "0"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://data.einnsyn.no/brukermeta/passord> "$2a$10$Rk0AwsnZYy30hRkKvEhVYO88M8dymkMVBNWfdC4oLEA5s0sCC43Y2" .
}} where {graph ?g {BIND(<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> as ?a) ?a ?b ?c}}

If I run these queries on parallel for the same user, I end up getting duplicate statements. eg: (see millis on timestamp)

<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://data.einnsyn.no/brukermeta/oppdatertDato> "2017-12-09T11:33:52.136+01:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://data.einnsyn.no/bruker/b1933b21-2100-45eb-a293-547aebda1d9e> <http://data.einnsyn.no/brukermeta/oppdatertDato> "2017-12-09T11:33:52.145+01:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .

I guess this is because I’m using SNAPSHOT isolation and not SERIALIZABLE. When I switch to SERIALIZABLE I never get duplicates.

Is there a way to achieve what I’m trying to do without switching over to SERIALIZABLE?

Cheers,
Håvard

Hi Håvard,

SERIALIZABLE exists specifically to deal with the issue you bring up here, so unfortunately there is no way to achieve this with SNAPSHOT

Ok. Thanks Stephen.

I’ll have to do some benchmarks then to see how it impacts performance.

Would be great to have subject-level locking as a new isolation level between SERIALIZABLE and SNAPSHOT.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.