Swirrl / drafter

A clojure service and a client to it for exposing data management operations to PMD
Other
0 stars 0 forks source link

Logging improvements #642

Closed RickMoynihan closed 1 year ago

RickMoynihan commented 1 year ago

This builds on and replaces Lee's PR #620. It fixes #615 through the following approach:

Firstly there are two log files:

These have different policies and purposes associated with them.

drafter.log

This log aims to provide the main summary / narrative of the whatever drafter is doing. The bulk of its contents should typically be the narrative around requests and jobs. Though it will also include initialisation messages etc. With this PR drafter.log won't contain the contents of any SPARQL queries.

sparql.log

This log contains SPARQL queries, and SPARQL updates.

This PR also contains changes which mean that by default we only log cache misses in the sparql.log. The reasoning here is that most of our queries are duplicates, so we can save some space and delay rotation longer by not logging the dupes. Stash hits should always return the same results anyway.

A SPARQL miss (against the public endpoint) looks like this in the logs:

2022-09-12T16:35:40,309 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=42fcc128} :: Stasher miss key: 828afb3e6717edbbeac962aacf715fa1 for tuple query:
SELECT  *
WHERE
  { ?s  ?p  ?o }
LIMIT   13

All misses contain the stasher key; so if we later discover something is wrong with a stash hit, we can search the cache key we report for the hit in the drafter.log. A hit for the same query above can be found in the drafter.log and looks like this:

2022-09-12T16:42:32,465 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=82148544} :: Stasher hit key: 828afb3e6717edbbeac962aacf715fa1 for tuple query (elided)

What if we've rotated the sparql.log so we no longer have a miss for a query?

This is no longer a problem, as I've made some code changes so that the queries are logged to the appropriate logs at two levels (info and debug). Hence if given a hash like 828afb3e6717edbbeac962aacf715fa1 and you want to discover what query it corresponds to you can simply change the level of drafter.rdf.sparql to debug in the log4j2.xml file on the production server.

This file is reloaded every 30 seconds, so after the changes are applied; recreate the action which you are debugging, and you will find the queries are now logged temporarily to the sparql.log for cache hits too. Just remember to set the flag back, as we will be logging many more duplicate queries, and consequently rotate this file quicker.

Sample output

Querying a draftset with a cached query

drafter.log output is currently, with nothing in sparql.log:

2022-09-12T17:56:19,768 INFO               logging       {reqId=2581399c} :: REQUEST /v1/draftset/48d1c79b-2b5f-4a02-a0b8-5ca626177eec/query text/csv {:query "<scrubbed>", :union-with-live "false"}
2022-09-12T17:56:20,063 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2581399c} :: Stasher hit key: f6ed5e0c337378d1d7bb460b919745f5 for boolean query (elided)
2022-09-12T17:56:20,077 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2581399c} :: Stasher hit key: 7c7020fb2af17cf65c485e49457fa30c for tuple query (elided)
2022-09-12T17:56:20,107 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2581399c} :: Stasher hit key: 1d2cac4ddbd34a63b442e085557e9fdc for tuple query (elided)
2022-09-12T17:56:20,127 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2581399c} :: Stasher hit key: 1d2cac4ddbd34a63b442e085557e9fdc for tuple query (elided)
2022-09-12T17:56:20,290 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2581399c} :: Stasher hit key: 16443e7c5aab211f4bf6e73b18292188 for tuple query (elided)
2022-09-12T17:56:20,291 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2581399c} :: Stasher hit key: de5f4bd4425f796cfeb996652bf35260 for tuple query (elided)
2022-09-12T17:56:20,294 INFO               logging       {reqId=2581399c} :: RESPONSE 200 headers sent after 576ms streaming body...

Creating a new draftset

drafter.log is:

2022-09-12T17:58:08,430 INFO               logging       {reqId=cf0e158e} :: REQUEST /v1/draftsets application/json {:display-name "test", :description "blah blah", :union-with-live "false"}
2022-09-12T17:58:08,503 INFO       write-scheduler 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=cf0e158e} :: Submitting sync job:  {:id #uuid "de5f0f4c-4566-457d-8aed-75d39b22c81a", :user-id 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :status :pending, :priority :blocking-write, :start-time 1663001888495, :finish-time nil, :draftset-id nil, :draft-graph-id nil, :metadata {:draftset nil, :operation create-draftset}, :function #function[drafter.async.jobs/wrap-logging-context/fn--29318], :value-p #promise[{:status :pending, :val nil} 0xa7aa932]}
2022-09-12T17:58:09,352 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {jobId=de5f0f4c, reqId=cf0e158e} :: Using new state graph last modified of: 2022-09-12T17:58:09.351+01:00_http://publishmydata.com/def/drafter/version/a2d796b3-93a2-4c18-9616-6f166ff215b3
2022-09-12T17:58:09,356 INFO               logging       {reqId=cf0e158e} :: RESPONSE 303 finished.  It took 933ms to execute
2022-09-12T17:58:09,378 INFO               logging       {reqId=2dfabddb} :: REQUEST /v1/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca application/json {}
2022-09-12T17:58:09,508 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2dfabddb} :: Stasher miss key: 40e72acc2077b35fffd44cabc31cca1a for boolean query
2022-09-12T17:58:09,652 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2dfabddb} :: Stasher miss key: a2f549f56541a8cc16df56f1e261e4a0 for tuple query
2022-09-12T17:58:09,724 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2dfabddb} :: Stasher miss key: 1bc8919988ae68388985e39d5289c72c for tuple query
2022-09-12T17:58:09,729 INFO               logging       {reqId=2dfabddb} :: RESPONSE 200 finished.  It took 351ms to execute

sparql.log is:

2022-09-12T17:58:09,508 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2dfabddb} :: Stasher miss key: 40e72acc2077b35fffd44cabc31cca1a for boolean query:
ASK WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> a <http://publishmydata.com/def/drafter/DraftSet> . }}
2022-09-12T17:58:09,653 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2dfabddb} :: Stasher miss key: a2f549f56541a8cc16df56f1e261e4a0 for tuple query:
SELECT * WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { ?ds <http://purl.org/dc/terms/created> ?created .?ds <http://purl.org/dc/terms/modified> ?modified .?ds <http://publishmydata.com/def/drafter/version> ?version .?ds <http://purl.org/dc/terms/creator> ?creator .OPTIONAL { ?ds <http://www.w3.org/2000/01/rdf-schema#comment> ?description . }OPTIONAL { ?ds <http://publishmydata.com/def/drafter/hasOwner> ?owner . }OPTIONAL { ?ds <http://www.w3.org/2000/01/rdf-schema#label> ?title . }OPTIONAL { ?ds <http://publishmydata.com/def/drafter/submittedBy> ?submitter. }OPTIONAL {  ?ds <http://publishmydata.com/def/drafter/hasSubmission> ?submission .  ?submission <http://publishmydata.com/def/drafter/claimUser> ?claimuser .}OPTIONAL {  ?ds <http://publishmydata.com/def/drafter/hasSubmission> ?submission .  ?submission <http://publishmydata.com/def/drafter/claimPermission> ?permission .}OPTIONAL {  SELECT ?ds (GROUP_CONCAT(?p; SEPARATOR=" ") AS ?viewpermissions)  WHERE { ?ds <http://publishmydata.com/def/drafter/viewPermission> ?p } GROUP BY ?ds}OPTIONAL {  SELECT ?ds (GROUP_CONCAT(?u; SEPARATOR=" ") AS ?viewusers)  WHERE { ?ds <http://publishmydata.com/def/drafter/viewUser> ?u } GROUP BY ?ds}{  SELECT DISTINCT ?ds WHERE {  ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .  { VALUES ?ds { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> } }  }} }}
2022-09-12T17:58:09,725 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=2dfabddb} :: Stasher miss key: 1bc8919988ae68388985e39d5289c72c for tuple query:
SELECT * WHERE {  GRAPH <http://publishmydata.com/graphs/drafter/drafts> { ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .?dg <http://publishmydata.com/def/drafter/inDraftSet> ?ds .?lg <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/ManagedGraph> .?lg <http://publishmydata.com/def/drafter/hasDraft> ?dg .?lg <http://publishmydata.com/def/drafter/isPublic> ?public .{  SELECT DISTINCT ?ds WHERE {  ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .{ VALUES ?ds { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> } }  }} }}

Appending a triple to a draftset

drafter.log:

2022-09-12T18:00:30,921 INFO               logging       {reqId=d3e12944} :: REQUEST /v1/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca/data application/json {:graph "http://1"}
2022-09-12T18:00:30,938 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=d3e12944} :: Stasher hit key: 40e72acc2077b35fffd44cabc31cca1a for boolean query (elided)
2022-09-12T18:00:31,071 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=d3e12944} :: Stasher miss key: 82ac4172d0390098634e4eda83b563a5 for tuple query
2022-09-12T18:00:31,147 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=d3e12944} :: Stasher hit key: a2f549f56541a8cc16df56f1e261e4a0 for tuple query (elided)
2022-09-12T18:00:31,160 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=d3e12944} :: Stasher hit key: 1bc8919988ae68388985e39d5289c72c for tuple query (elided)
2022-09-12T18:00:31,183 INFO       write-scheduler 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=d3e12944} :: Submitting async job:  {:id #uuid "e91bc7ff-f6dd-445f-9c33-08fb0c546fdc", :user-id 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :status :pending, :priority :background-write, :start-time 1663002031174, :finish-time nil, :draftset-id #drafter.draftset.DraftsetId{:id 1d90c10b-7fc0-4a15-a0b2-545b013876ca}, :draft-graph-id nil, :metadata {:draftset {:description blah blah, :updated-at #object[java.time.OffsetDateTime 0x5443948b 2022-09-12T16:58:08.508Z], :type Draftset, :current-owner 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :created-by 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :id 1d90c10b-7fc0-4a15-a0b2-545b013876ca, :display-name test, :changes {}, :version #object[java.net.URI 0x46e7c5bc http://publishmydata.com/def/drafter/version/d4396bdc-56bf-48ef-85a2-937a9ec71153], :created-at #object[java.time.OffsetDateTime 0x49a0eaab 2022-09-12T16:58:08.508Z]}, :operation append-data-to-draftset}, :function #function[drafter.async.jobs/wrap-logging-context/fn--29318], :value-p #promise[{:status :pending, :val nil} 0x455f1d39]}
2022-09-12T18:00:31,194 INFO       write-scheduler 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=d3e12944} :: Queueing job:  {:id #uuid "e91bc7ff-f6dd-445f-9c33-08fb0c546fdc", :user-id 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :status :pending, :priority :background-write, :start-time 1663002031174, :finish-time nil, :draftset-id #drafter.draftset.DraftsetId{:id 1d90c10b-7fc0-4a15-a0b2-545b013876ca}, :draft-graph-id nil, :metadata {:draftset {:description blah blah, :updated-at #object[java.time.OffsetDateTime 0x5443948b 2022-09-12T16:58:08.508Z], :type Draftset, :current-owner 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :created-by 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :id 1d90c10b-7fc0-4a15-a0b2-545b013876ca, :display-name test, :changes {}, :version #object[java.net.URI 0x46e7c5bc http://publishmydata.com/def/drafter/version/d4396bdc-56bf-48ef-85a2-937a9ec71153], :created-at #object[java.time.OffsetDateTime 0x49a0eaab 2022-09-12T16:58:08.508Z]}, :operation append-data-to-draftset}, :function #function[drafter.async.jobs/wrap-logging-context/fn--29318], :value-p #promise[{:status :pending, :val nil} 0x455f1d39]} {:reqId d3e12944, :method :put, :route /draftset/:id/data}
2022-09-12T18:00:31,198 INFO               logging       {reqId=d3e12944} :: RESPONSE 202 finished.  It took 278ms to execute
2022-09-12T18:00:31,201 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Stasher hit key: 1bc8919988ae68388985e39d5289c72c for tuple query (elided)
2022-09-12T18:00:31,528 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Stasher miss key: 9a0cd811ce09322cc308640e4cbb7d92 for boolean query
2022-09-12T18:00:31,621 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Stasher miss key: 92f698c29aade0b27c6ab674296c30ab for boolean query
2022-09-12T18:00:31,780 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Using new state graph last modified of: 2022-09-12T18:00:31.779+01:00_http://publishmydata.com/def/drafter/version/bee78a5f-28f0-4353-983a-4c83ac49d144
2022-09-12T18:00:31,786 INFO                common       {jobId=e91bc7ff, reqId=d3e12944} :: Acquired lock for  :copy-graph
2022-09-12T18:00:32,060 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Using new state graph last modified of: 2022-09-12T18:00:32.059+01:00_http://publishmydata.com/def/drafter/version/5322c398-ef51-48f7-bb44-09edd68bed13
2022-09-12T18:00:32,060 INFO                common       {jobId=e91bc7ff, reqId=d3e12944} :: Releasing lock for :copy-graph
2022-09-12T18:00:32,079 INFO       write-scheduler       {jobId=e91bc7ff, reqId=d3e12944} :: Queueing job:  {:id #uuid "e91bc7ff-f6dd-445f-9c33-08fb0c546fdc", :user-id 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :status :pending, :priority :background-write, :start-time 1663002032061, :finish-time nil, :draftset-id #drafter.draftset.DraftsetId{:id 1d90c10b-7fc0-4a15-a0b2-545b013876ca}, :draft-graph-id nil, :metadata {:draftset {:description blah blah, :updated-at #object[java.time.OffsetDateTime 0x5443948b 2022-09-12T16:58:08.508Z], :type Draftset, :current-owner 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :created-by 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :id 1d90c10b-7fc0-4a15-a0b2-545b013876ca, :display-name test, :changes {}, :version #object[java.net.URI 0x46e7c5bc http://publishmydata.com/def/drafter/version/d4396bdc-56bf-48ef-85a2-937a9ec71153], :created-at #object[java.time.OffsetDateTime 0x49a0eaab 2022-09-12T16:58:08.508Z]}, :operation append-data-to-draftset}, :function #function[clojure.core/partial/fn--5857], :value-p #promise[{:status :pending, :val nil} 0x455f1d39]} {:reqId d3e12944, :method :put, :route /draftset/:id/data}
2022-09-12T18:00:32,080 INFO       write-scheduler       {jobId=e91bc7ff, reqId=d3e12944} :: task took 885ms
2022-09-12T18:00:32,144 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Using new state graph last modified of: 2022-09-12T18:00:32.144+01:00_http://publishmydata.com/def/drafter/version/19ecf0c9-2f7b-4a19-bf73-282c1b891b23
2022-09-12T18:00:32,977 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Using new state graph last modified of: 2022-09-12T18:00:32.977+01:00_http://publishmydata.com/def/drafter/version/aec1bfa5-c454-4d0b-9aa7-44b01ce5641d
2022-09-12T18:00:33,031 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Stasher miss key: 1bc8919988ae68388985e39d5289c72c for tuple query
2022-09-12T18:00:33,052 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Stasher miss key: 94f9b16da1528220a2324aeb03a848cd for boolean query
2022-09-12T18:00:33,090 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Using new state graph last modified of: 2022-09-12T18:00:33.090+01:00_http://publishmydata.com/def/drafter/version/1284ad45-95e0-48e1-9eee-b86322c4a26c
2022-09-12T18:00:33,262 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Using new state graph last modified of: 2022-09-12T18:00:33.262+01:00_http://publishmydata.com/def/drafter/version/f67c8a93-9e57-48bf-a2fd-a761aa3176be
2022-09-12T18:00:33,338 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Using new state graph last modified of: 2022-09-12T18:00:33.338+01:00_http://publishmydata.com/def/drafter/version/9bdef813-d8bb-4367-a6da-6101507c17ce
2022-09-12T18:00:33,389 INFO               stasher       {jobId=e91bc7ff, reqId=d3e12944} :: Using new state graph last modified of: 2022-09-12T18:00:33.389+01:00_http://publishmydata.com/def/drafter/version/225c4998-5821-431a-b971-b0cd34231845
2022-09-12T18:00:33,392 INFO       write-scheduler       {jobId=e91bc7ff, reqId=d3e12944} :: task took 1312ms

sparql.log:

2022-09-12T18:00:02,038 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=d6c0e62b} :: Stasher miss key: aad78e2e0f3c96a2d32217b749813028 for boolean query:
ASK WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { <http://publishmydata.com/def/drafter/draftset/de5f0f4c-4566-457d-8aed-75d39b22c81a> a <http://publishmydata.com/def/drafter/DraftSet> . }}
2022-09-12T18:00:31,072 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=d3e12944} :: Stasher miss key: 82ac4172d0390098634e4eda83b563a5 for tuple query:
SELECT ?owner WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .<http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://publishmydata.com/def/drafter/hasOwner> ?owner . }} LIMIT 1
2022-09-12T18:00:31,530 INFO                sparql       {jobId=e91bc7ff, reqId=d3e12944} :: Stasher miss key: 9a0cd811ce09322cc308640e4cbb7d92 for boolean query:
ASK WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> {    <http://1> a <http://publishmydata.com/def/drafter/ManagedGraph> .   <http://1> <http://publishmydata.com/def/drafter/isPublic> true .} }
2022-09-12T18:00:31,621 INFO                sparql       {jobId=e91bc7ff, reqId=d3e12944} :: Stasher miss key: 92f698c29aade0b27c6ab674296c30ab for boolean query:
ASK WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { <http://1> a <http://publishmydata.com/def/drafter/ManagedGraph> .} }
2022-09-12T18:00:31,787 INFO                sparql       {jobId=e91bc7ff, reqId=d3e12944} :: Running update:  
COPY SILENT <http://1> TO <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d>
2022-09-12T18:00:32,147 INFO                sparql       {jobId=e91bc7ff, reqId=d3e12944} :: Running update:  
DELETE {
  GRAPH ?g { ?lg ?p ?o }
}
INSERT {
  GRAPH ?g { ?dg ?p ?o }
}
WHERE {
  GRAPH ?g { ?lg ?p ?o }

  GRAPH <http://publishmydata.com/graphs/drafter/drafts> {
      ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .
      ?g <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?dg <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?lg <http://publishmydata.com/def/drafter/hasDraft> ?dg .

    FILTER EXISTS { GRAPH ?dg { ?s_ ?p_ ?o_ } }
    VALUES ?ds { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> }
  }
};

DELETE {
  GRAPH ?g { ?s ?lg ?o }
}
INSERT {
  GRAPH ?g { ?s ?dg ?o }
}
WHERE {
  GRAPH ?g { ?s ?lg ?o }

  GRAPH <http://publishmydata.com/graphs/drafter/drafts> {
      ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .
      ?g <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?dg <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?lg <http://publishmydata.com/def/drafter/hasDraft> ?dg .

    FILTER EXISTS { GRAPH ?dg { ?s_ ?p_ ?o_ } }
    VALUES ?ds { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> }
  }
};

DELETE {
  GRAPH ?g { ?s ?p ?lg }
}
INSERT {
  GRAPH ?g { ?s ?p ?dg }
}
WHERE {
  GRAPH ?g { ?s ?p ?lg }

  GRAPH <http://publishmydata.com/graphs/drafter/drafts> {
      ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .
      ?g <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?dg <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?lg <http://publishmydata.com/def/drafter/hasDraft> ?dg .

    FILTER EXISTS { GRAPH ?dg { ?s_ ?p_ ?o_ } }
    VALUES ?ds { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> }
  }
}
2022-09-12T18:00:33,031 INFO                sparql       {jobId=e91bc7ff, reqId=d3e12944} :: Stasher miss key: 1bc8919988ae68388985e39d5289c72c for tuple query:
SELECT * WHERE {  GRAPH <http://publishmydata.com/graphs/drafter/drafts> { ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .?dg <http://publishmydata.com/def/drafter/inDraftSet> ?ds .?lg <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/ManagedGraph> .?lg <http://publishmydata.com/def/drafter/hasDraft> ?dg .?lg <http://publishmydata.com/def/drafter/isPublic> ?public .{  SELECT DISTINCT ?ds WHERE {  ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .{ VALUES ?ds { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> } }  }} }}
2022-09-12T18:00:33,052 INFO                sparql       {jobId=e91bc7ff, reqId=d3e12944} :: Stasher miss key: 94f9b16da1528220a2324aeb03a848cd for boolean query:
ASK WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { <http://publishmydata.com/graphs/drafter/graph-modified-times> a <http://publishmydata.com/def/drafter/ManagedGraph> .} }
2022-09-12T18:00:33,119 INFO                sparql       {jobId=e91bc7ff, reqId=d3e12944} :: Running update:  PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX drafter: <http://publishmydata.com/def/drafter/>

DELETE {
    GRAPH <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> {
        <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> dcterms:modified ?olddmg .
        <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> dcterms:modified ?olddraft .
    }
} WHERE {
    GRAPH <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> {
        <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> dcterms:modified ?olddmg .
        OPTIONAL { <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> dcterms:modified ?olddraft . }
    }
} ;
INSERT DATA {
    GRAPH <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> {
        <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> dcterms:modified "2022-09-12T17:00:31.204Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
        <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> dcterms:modified "2022-09-12T17:00:31.204Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
    }
}

2022-09-12T18:00:33,266 INFO                sparql       {jobId=e91bc7ff, reqId=d3e12944} :: Running update:  WITH <http://publishmydata.com/graphs/drafter/drafts>DELETE {   <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://purl.org/dc/terms/modified> ?lastvalue .}INSERT {    <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://purl.org/dc/terms/modified> "2022-09-12T17:00:31.204Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .}WHERE {   <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> ?p ?o .   OPTIONAL {     <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://purl.org/dc/terms/modified> ?lastvalue .  }}
2022-09-12T18:00:33,339 INFO                sparql       {jobId=e91bc7ff, reqId=d3e12944} :: Running update:  WITH <http://publishmydata.com/graphs/drafter/drafts>DELETE {   <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://publishmydata.com/def/drafter/version> ?lastvalue .}INSERT {    <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://publishmydata.com/def/drafter/version> <http://publishmydata.com/def/drafter/version/4f6890d8-fc54-4c13-93b3-af67e395a7c3> .}WHERE {   <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> ?p ?o .   OPTIONAL {     <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://publishmydata.com/def/drafter/version> ?lastvalue .  }}

Publishing a draftset

drafter.log:

2022-09-12T18:02:24,219 INFO               logging       {reqId=e51760c6} :: REQUEST /v1/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca/publish application/json {}
2022-09-12T18:02:24,432 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: 40e72acc2077b35fffd44cabc31cca1a for boolean query
2022-09-12T18:02:24,491 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: 82ac4172d0390098634e4eda83b563a5 for tuple query
2022-09-12T18:02:24,637 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: a2f549f56541a8cc16df56f1e261e4a0 for tuple query
2022-09-12T18:02:24,695 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: 1bc8919988ae68388985e39d5289c72c for tuple query
2022-09-12T18:02:24,722 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: 295aff35141a4f9ce7c597466be37ebf for boolean query
2022-09-12T18:02:24,745 INFO               stasher 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: 11bf925efbbf71e8421370926b63dd0a for boolean query
2022-09-12T18:02:24,748 INFO       write-scheduler 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Submitting async job:  {:id #uuid "94971f0b-2623-4eac-be8c-74e91ae0e0a1", :user-id 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :status :pending, :priority :publish-write, :start-time 1663002144747, :finish-time nil, :draftset-id #drafter.draftset.DraftsetId{:id 1d90c10b-7fc0-4a15-a0b2-545b013876ca}, :draft-graph-id nil, :metadata {:draftset {:description blah blah, :updated-at #object[java.time.OffsetDateTime 0x266ffb13 2022-09-12T17:00:31.204Z], :type Draftset, :current-owner 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :created-by 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :id 1d90c10b-7fc0-4a15-a0b2-545b013876ca, :display-name test, :changes {#object[java.net.URI 0x6bbb99a8 http://publishmydata.com/graphs/drafter/graph-modified-times] {:status :updated}, #object[java.net.URI 0x51b2221f http://1] {:status :updated}}, :version #object[java.net.URI 0x74c2b82f http://publishmydata.com/def/drafter/version/4f6890d8-fc54-4c13-93b3-af67e395a7c3], :created-at #object[java.time.OffsetDateTime 0x2d2c62c7 2022-09-12T16:58:08.508Z]}, :operation publish-draftset}, :function #function[drafter.async.jobs/wrap-logging-context/fn--29318], :value-p #promise[{:status :pending, :val nil} 0x1a6dc813]}
2022-09-12T18:02:24,748 INFO       write-scheduler 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Queueing job:  {:id #uuid "94971f0b-2623-4eac-be8c-74e91ae0e0a1", :user-id 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :status :pending, :priority :publish-write, :start-time 1663002144747, :finish-time nil, :draftset-id #drafter.draftset.DraftsetId{:id 1d90c10b-7fc0-4a15-a0b2-545b013876ca}, :draft-graph-id nil, :metadata {:draftset {:description blah blah, :updated-at #object[java.time.OffsetDateTime 0x266ffb13 2022-09-12T17:00:31.204Z], :type Draftset, :current-owner 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :created-by 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients, :id 1d90c10b-7fc0-4a15-a0b2-545b013876ca, :display-name test, :changes {#object[java.net.URI 0x6bbb99a8 http://publishmydata.com/graphs/drafter/graph-modified-times] {:status :updated}, #object[java.net.URI 0x51b2221f http://1] {:status :updated}}, :version #object[java.net.URI 0x74c2b82f http://publishmydata.com/def/drafter/version/4f6890d8-fc54-4c13-93b3-af67e395a7c3], :created-at #object[java.time.OffsetDateTime 0x2d2c62c7 2022-09-12T16:58:08.508Z]}, :operation publish-draftset}, :function #function[drafter.async.jobs/wrap-logging-context/fn--29318], :value-p #promise[{:status :pending, :val nil} 0x1a6dc813]} {:reqId e51760c6, :method :post, :route /draftset/:id/publish}
2022-09-12T18:02:24,748 INFO               logging       {reqId=e51760c6} :: RESPONSE 202 finished.  It took 533ms to execute
2022-09-12T18:02:24,749 INFO       write-scheduler       {jobId=94971f0b, reqId=e51760c6} :: Acquired lock for  :publish-write
2022-09-12T18:02:24,756 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Stasher hit key: 1bc8919988ae68388985e39d5289c72c for tuple query (elided)
2022-09-12T18:02:24,757 INFO      draft-management       {jobId=94971f0b, reqId=e51760c6} :: Starting make-live for graphs  (#object[java.net.URI 0x5a71a0cf http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d])
2022-09-12T18:02:24,793 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: c6399be36cec4fb0a4d88894556e3cf8 for tuple query
2022-09-12T18:02:24,842 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: fb8ad6862d188ecb13e1974e3a471062 for boolean query
2022-09-12T18:02:25,163 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Using new state graph last modified of: 2022-09-12T18:02:25.163+01:00_http://publishmydata.com/def/drafter/version/9bbc2237-02c7-4783-bf7d-a26619b42a0e
2022-09-12T18:02:25,164 INFO      draft-management       {jobId=94971f0b, reqId=e51760c6} :: Make-live for graph(s)  (#object[java.net.URI 0x5a71a0cf http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d])  done
2022-09-12T18:02:25,230 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: da404930e417139c3934dfd581479d37 for tuple query
2022-09-12T18:02:25,357 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: 8e68ddea599a157a848808e2e111c51a for tuple query
2022-09-12T18:02:25,387 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: fbca3683d3766efdefc684643d0e1ffd for tuple query
2022-09-12T18:02:25,475 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: 73a7fc90adb3c8709fce7ef4457fa479 for tuple query
2022-09-12T18:02:25,518 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: d4583443841b30f585b93e9ad62ea3e0 for tuple query
2022-09-12T18:02:25,610 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Using new state graph last modified of: 2022-09-12T18:02:25.607+01:00_http://publishmydata.com/def/drafter/version/70fdad02-d156-4d15-a18c-37675021ad1f
2022-09-12T18:02:25,679 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Using new state graph last modified of: 2022-09-12T18:02:25.679+01:00_http://publishmydata.com/def/drafter/version/2f4d70ca-f6ec-4686-b099-edd84d6dae92
2022-09-12T18:02:25,730 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Using new state graph last modified of: 2022-09-12T18:02:25.729+01:00_http://publishmydata.com/def/drafter/version/e4b94c79-8504-4958-9d85-0386062e6647
2022-09-12T18:02:25,794 INFO               stasher       {jobId=94971f0b, reqId=e51760c6} :: Using new state graph last modified of: 2022-09-12T18:02:25.793+01:00_http://publishmydata.com/def/drafter/version/27c19290-2bd2-4207-ba62-94da4163bd4a
2022-09-12T18:02:25,794 INFO       write-scheduler       {jobId=94971f0b, reqId=e51760c6} :: Releasing lock for :publish-write
2022-09-12T18:02:25,794 INFO       write-scheduler       {jobId=94971f0b, reqId=e51760c6} :: task took 1046ms

sparql.log:

2022-09-12T18:02:24,432 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: 40e72acc2077b35fffd44cabc31cca1a for boolean query:
ASK WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> a <http://publishmydata.com/def/drafter/DraftSet> . }}
2022-09-12T18:02:24,491 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: 82ac4172d0390098634e4eda83b563a5 for tuple query:
SELECT ?owner WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .<http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://publishmydata.com/def/drafter/hasOwner> ?owner . }} LIMIT 1
2022-09-12T18:02:24,637 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: a2f549f56541a8cc16df56f1e261e4a0 for tuple query:
SELECT * WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { ?ds <http://purl.org/dc/terms/created> ?created .?ds <http://purl.org/dc/terms/modified> ?modified .?ds <http://publishmydata.com/def/drafter/version> ?version .?ds <http://purl.org/dc/terms/creator> ?creator .OPTIONAL { ?ds <http://www.w3.org/2000/01/rdf-schema#comment> ?description . }OPTIONAL { ?ds <http://publishmydata.com/def/drafter/hasOwner> ?owner . }OPTIONAL { ?ds <http://www.w3.org/2000/01/rdf-schema#label> ?title . }OPTIONAL { ?ds <http://publishmydata.com/def/drafter/submittedBy> ?submitter. }OPTIONAL {  ?ds <http://publishmydata.com/def/drafter/hasSubmission> ?submission .  ?submission <http://publishmydata.com/def/drafter/claimUser> ?claimuser .}OPTIONAL {  ?ds <http://publishmydata.com/def/drafter/hasSubmission> ?submission .  ?submission <http://publishmydata.com/def/drafter/claimPermission> ?permission .}OPTIONAL {  SELECT ?ds (GROUP_CONCAT(?p; SEPARATOR=" ") AS ?viewpermissions)  WHERE { ?ds <http://publishmydata.com/def/drafter/viewPermission> ?p } GROUP BY ?ds}OPTIONAL {  SELECT ?ds (GROUP_CONCAT(?u; SEPARATOR=" ") AS ?viewusers)  WHERE { ?ds <http://publishmydata.com/def/drafter/viewUser> ?u } GROUP BY ?ds}{  SELECT DISTINCT ?ds WHERE {  ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .  { VALUES ?ds { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> } }  }} }}
2022-09-12T18:02:24,695 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: 1bc8919988ae68388985e39d5289c72c for tuple query:
SELECT * WHERE {  GRAPH <http://publishmydata.com/graphs/drafter/drafts> { ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .?dg <http://publishmydata.com/def/drafter/inDraftSet> ?ds .?lg <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/ManagedGraph> .?lg <http://publishmydata.com/def/drafter/hasDraft> ?dg .?lg <http://publishmydata.com/def/drafter/isPublic> ?public .{  SELECT DISTINCT ?ds WHERE {  ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .{ VALUES ?ds { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> } }  }} }}
2022-09-12T18:02:24,723 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: 295aff35141a4f9ce7c597466be37ebf for boolean query:
ASK WHERE {  GRAPH <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> { ?s ?p ?o }}
2022-09-12T18:02:24,745 INFO                sparql 3aOjbCpb7AlfXLJFpHpqYZfWlI5Gl0ce@clients {reqId=e51760c6} :: Stasher miss key: 11bf925efbbf71e8421370926b63dd0a for boolean query:
ASK WHERE {  GRAPH <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> { ?s ?p ?o }}
2022-09-12T18:02:24,793 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: c6399be36cec4fb0a4d88894556e3cf8 for tuple query:
SELECT ?live WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { ?live a <http://publishmydata.com/def/drafter/ManagedGraph> ;      <http://publishmydata.com/def/drafter/hasDraft> <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> .  }} LIMIT 1
2022-09-12T18:02:24,842 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: fb8ad6862d188ecb13e1974e3a471062 for boolean query:
ASK WHERE {
    SELECT * WHERE {
      GRAPH <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> { ?s ?p ?o }
    } LIMIT 1
  }
2022-09-12T18:02:24,843 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Running update:  
DELETE {
  GRAPH ?g { ?dg ?p ?o }
}
INSERT {
  GRAPH ?g { ?lg ?p ?o }
}
WHERE {
  GRAPH ?g { ?dg ?p ?o }

  GRAPH <http://publishmydata.com/graphs/drafter/drafts> {
      ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .
      ?g <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?dg <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?lg <http://publishmydata.com/def/drafter/hasDraft> ?dg .

    VALUES ?dg { <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> }
  }
};

DELETE {
  GRAPH ?g { ?s ?dg ?o }
}
INSERT {
  GRAPH ?g { ?s ?lg ?o }
}
WHERE {
  GRAPH ?g { ?s ?dg ?o }

  GRAPH <http://publishmydata.com/graphs/drafter/drafts> {
      ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .
      ?g <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?dg <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?lg <http://publishmydata.com/def/drafter/hasDraft> ?dg .

    VALUES ?dg { <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> }
  }
};

DELETE {
  GRAPH ?g { ?s ?p ?dg }
}
INSERT {
  GRAPH ?g { ?s ?p ?lg }
}
WHERE {
  GRAPH ?g { ?s ?p ?dg }

  GRAPH <http://publishmydata.com/graphs/drafter/drafts> {
      ?ds <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .
      ?g <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?dg <http://publishmydata.com/def/drafter/inDraftSet> ?ds .
      ?lg <http://publishmydata.com/def/drafter/hasDraft> ?dg .

    VALUES ?dg { <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> }
  }
};
# set a dcterms:issued timestamp if it doesn't have one already
WITH <http://publishmydata.com/graphs/drafter/drafts> INSERT {  ?live <http://purl.org/dc/terms/issued> "2022-09-12T17:02:24.757Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .} WHERE {  VALUES ?draft { <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> }  ?live a <http://publishmydata.com/def/drafter/ManagedGraph> ;        <http://publishmydata.com/def/drafter/hasDraft> ?draft .  FILTER NOT EXISTS { ?live <http://purl.org/dc/terms/issued> ?existing . }};
MOVE SILENT <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> TO <http://1>;
WITH <http://publishmydata.com/graphs/drafter/drafts>DELETE {   ?live <http://publishmydata.com/def/drafter/hasDraft> <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> .   <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> ?p ?o .} WHERE {   ?live a <http://publishmydata.com/def/drafter/ManagedGraph> ;         <http://publishmydata.com/def/drafter/hasDraft> <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> .   <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> ?p ?o . };
WITH <http://publishmydata.com/graphs/drafter/drafts> DELETE {   <http://1> <http://publishmydata.com/def/drafter/isPublic> ?o .} INSERT {   <http://1> <http://publishmydata.com/def/drafter/isPublic> true . } WHERE {   OPTIONAL { <http://1> <http://publishmydata.com/def/drafter/isPublic> ?o }}
2022-09-12T18:02:25,233 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: da404930e417139c3934dfd581479d37 for tuple query:
SELECT ?live WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { ?live a <http://publishmydata.com/def/drafter/ManagedGraph> ;      <http://publishmydata.com/def/drafter/isPublic> true . }}
2022-09-12T18:02:25,359 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: 8e68ddea599a157a848808e2e111c51a for tuple query:
prefix dcterms: <http://purl.org/dc/terms/>
prefix drafter: <http://publishmydata.com/def/drafter/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix draft: <http://publishmydata.com/graphs/drafter/draft>
prefix draftset: <http://publishmydata.com/def/drafter/draftset/>

SELECT ?livemod ?livever ?draftmod ?draftver WHERE {
  OPTIONAL {
    SELECT ?livemod ?livever WHERE {
      VALUES ?graph { <urn:private-graph-to-force-restrictions-when-no-graphs-are-listed> <http://publishmydata.com/graphs/drafter/graph-modified-times> <http://1> }
      GRAPH <http://publishmydata.com/graphs/drafter/drafts> {
        ?graph a drafter:ManagedGraph ;
               drafter:isPublic true .
      }
      GRAPH <http://publishmydata.com/graphs/drafter/graph-modified-times> {
          ?graph dcterms:modified ?livemod .
      }
      GRAPH <http://publishmydata.com/graphs/drafter/endpoints> {
        drafter:public drafter:version ?livever .
      }
    }
  }

  OPTIONAL {
    SELECT ?draftmod ?draftver WHERE {
      VALUES ?graph { <urn:private-graph-to-force-restrictions-when-no-graphs-are-listed> <http://publishmydata.com/graphs/drafter/graph-modified-times> <http://1> }
      GRAPH <http://publishmydata.com/graphs/drafter/drafts> {
        ?graph a drafter:DraftGraph ;
               drafter:inDraftSet ?ds .
        ?ds drafter:version ?draftver .
        ?lg drafter:hasDraft ?graph .
        <http://publishmydata.com/graphs/drafter/graph-modified-times> drafter:hasDraft ?dmg .
        ?dmg drafter:inDraftSet ?ds .
      }

      GRAPH ?dmg {
        ?graph dcterms:modified ?draftmod .
      }
    }
  }
} ORDER BY DESC(?livemod) DESC(?draftmod) LIMIT 1
2022-09-12T18:02:25,387 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: fbca3683d3766efdefc684643d0e1ffd for tuple query:
PREFIX drafter: <http://publishmydata.com/def/drafter/>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?lg ?modified WHERE {
    GRAPH <http://publishmydata.com/graphs/drafter/graph-modified-times> {
        ?lg dcterms:modified ?modified .
    }
}
2022-09-12T18:02:25,475 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: 73a7fc90adb3c8709fce7ef4457fa479 for tuple query:
prefix dcterms: <http://purl.org/dc/terms/>
prefix drafter: <http://publishmydata.com/def/drafter/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix draft: <http://publishmydata.com/graphs/drafter/draft>
prefix draftset: <http://publishmydata.com/def/drafter/draftset/>

SELECT ?livemod ?livever ?draftmod ?draftver WHERE {
  OPTIONAL {
    SELECT ?livemod ?livever WHERE {
      VALUES ?graph { <urn:private-graph-to-force-restrictions-when-no-graphs-are-listed> <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> }
      GRAPH <http://publishmydata.com/graphs/drafter/drafts> {
        ?graph a drafter:ManagedGraph ;
               drafter:isPublic true .
      }
      GRAPH <http://publishmydata.com/graphs/drafter/graph-modified-times> {
          ?graph dcterms:modified ?livemod .
      }
      GRAPH <http://publishmydata.com/graphs/drafter/endpoints> {
        drafter:public drafter:version ?livever .
      }
    }
  }

  OPTIONAL {
    SELECT ?draftmod ?draftver WHERE {
      VALUES ?graph { <urn:private-graph-to-force-restrictions-when-no-graphs-are-listed> <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> <http://publishmydata.com/graphs/drafter/draft/f1e5aed6-e4f9-4913-a9db-d614b608349d> }
      GRAPH <http://publishmydata.com/graphs/drafter/drafts> {
        ?graph a drafter:DraftGraph ;
               drafter:inDraftSet ?ds .
        ?ds drafter:version ?draftver .
        ?lg drafter:hasDraft ?graph .
        <http://publishmydata.com/graphs/drafter/graph-modified-times> drafter:hasDraft ?dmg .
        ?dmg drafter:inDraftSet ?ds .
      }

      GRAPH ?dmg {
        ?graph dcterms:modified ?draftmod .
      }
    }
  }
} ORDER BY DESC(?livemod) DESC(?draftmod) LIMIT 1
2022-09-12T18:02:25,518 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Stasher miss key: d4583443841b30f585b93e9ad62ea3e0 for tuple query:
PREFIX  drafter: <http://publishmydata.com/def/drafter/>
PREFIX  dcterms: <http://purl.org/dc/terms/>

SELECT  ?lg ?modified
WHERE
  { GRAPH <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb>
      { ?lg  dcterms:modified  ?modified }
  }

2022-09-12T18:02:25,527 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Running update:  PREFIX dcterms: <http://purl.org/dc/terms/>DELETE {  GRAPH <http://publishmydata.com/graphs/drafter/graph-modified-times> {    ?g dcterms:modified ?modified .  }} WHERE {  GRAPH <http://publishmydata.com/graphs/drafter/graph-modified-times> {    VALUES ?g { <http://publishmydata.com/graphs/drafter/graph-modified-times> <http://1> }    ?g dcterms:modified ?modified .  }} ;INSERT DATA {  GRAPH <http://publishmydata.com/graphs/drafter/graph-modified-times> {<http://publishmydata.com/graphs/drafter/graph-modified-times> dcterms:modified "2022-09-12T17:00:31.204Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://1> dcterms:modified "2022-09-12T17:00:31.204Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .  }};
WITH <http://publishmydata.com/graphs/drafter/drafts> DELETE {   <http://publishmydata.com/graphs/drafter/graph-modified-times> <http://publishmydata.com/def/drafter/isPublic> ?o .} INSERT {   <http://publishmydata.com/graphs/drafter/graph-modified-times> <http://publishmydata.com/def/drafter/isPublic> true . } WHERE {   OPTIONAL { <http://publishmydata.com/graphs/drafter/graph-modified-times> <http://publishmydata.com/def/drafter/isPublic> ?o }};
WITH <http://publishmydata.com/graphs/drafter/drafts>DELETE {   ?live <http://publishmydata.com/def/drafter/hasDraft> <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> .   <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> ?p ?o .} WHERE {   ?live a <http://publishmydata.com/def/drafter/ManagedGraph> ;         <http://publishmydata.com/def/drafter/hasDraft> <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> .   <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb> ?p ?o . };
DROP SILENT GRAPH <http://publishmydata.com/graphs/drafter/draft/5dc7f8d8-ab84-484d-a623-2576b3e17cdb>
2022-09-12T18:02:25,615 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Running update:  PREFIX drafter: <http://publishmydata.com/def/drafter/>
PREFIX dcterms: <http://purl.org/dc/terms/>

DELETE {
  GRAPH <http://publishmydata.com/graphs/drafter/endpoints> {
    drafter:public dcterms:modified ?pem .
  }
} INSERT {
  GRAPH <http://publishmydata.com/graphs/drafter/endpoints> {
    drafter:public dcterms:modified ?updated .
  }
} WHERE {
  GRAPH <http://publishmydata.com/graphs/drafter/endpoints> {
    drafter:public dcterms:modified ?pem .
  }
  BIND(NOW() AS ?updated)
}

2022-09-12T18:02:25,679 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Running update:  PREFIX drafter: <http://publishmydata.com/def/drafter/>

WITH <http://publishmydata.com/graphs/drafter/endpoints>
DELETE {
  drafter:public drafter:version ?old .
} INSERT {
  drafter:public drafter:version ?new .
} WHERE {
  BIND(
    IRI(CONCAT("http://publishmydata.com/def/drafter/version/", STRUUID()))
    AS ?new
  )
  # Insert a version even if there isn't an old one to delete.
  OPTIONAL {
    drafter:public drafter:version ?old .
  }
}

2022-09-12T18:02:25,731 INFO                sparql       {jobId=94971f0b, reqId=e51760c6} :: Running update:  DELETE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> ?dp ?do .?submission ?sp ?so . }} WHERE { GRAPH <http://publishmydata.com/graphs/drafter/drafts> { <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://publishmydata.com/def/drafter/DraftSet> .<http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> ?dp ?do .OPTIONAL {  <http://publishmydata.com/def/drafter/draftset/1d90c10b-7fc0-4a15-a0b2-545b013876ca> <http://publishmydata.com/def/drafter/hasSubmission> ?submission .  ?submission ?sp ?so .} }}