From 8f60fde7f5499e5ffe352d7ae98a2de34a91b89f Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 24 Jun 2022 15:58:26 +0530 Subject: Try uploading twice into virtuoso. * load-rdf.scm (put-graph): Accept retry? argument, and retry if it is #t. (main): Call put-graph with a #t retry? argument. --- load-rdf.scm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/load-rdf.scm b/load-rdf.scm index f6e0f62..c390a1b 100755 --- a/load-rdf.scm +++ b/load-rdf.scm @@ -116,7 +116,7 @@ PROC." (zero? return-value)) (error "Invocation of program failed" (cons program args)))))))) -(define (put-graph sparql-endpoint username password rdf-file graph) +(define* (put-graph sparql-endpoint username password rdf-file graph #:optional retry?) "Load RDF-FILE into GRAPH at SPARQL-ENDPOINT, a SPARQL 1.1 Graph Store HTTP Protocol endpoint, authenticating with USERNAME and PASSWORD. The PUT method is used, and therefore, any existing data in @@ -134,7 +134,13 @@ the graph is deleted." (unless (= (quotient (response-code response) 100) 2) - (error "Putting graph failed" response)))) + ;; When uploading a large RDF file into a clean virtuoso, it + ;; fails for the first time, and succeeds only the second + ;; time. It is unclear why. So, perform this ugly hack of trying + ;; twice. + (if retry? + (put-graph sparql-endpoint username password rdf-file graph #f) + (error "Putting graph failed" response))))) (define (delete-graph port graph) "Delete GRAPH from virtuoso connecting to virtuoso on PORT." @@ -185,7 +191,8 @@ the graph is deleted." (assq-ref connection-settings 'virtuoso-username) (assq-ref connection-settings 'virtuoso-password) rdf-file - %graph-uri))))) + %graph-uri + #t))))) ((arg0 _ ...) (format (current-error-port) "Usage: ~a CONNECTION-SETTINGS-FILE RDF-FILE~%" arg0) (exit #f)))) -- cgit v1.2.3