While our new RDF::Repository implementation theoretically improves the concurrency story for RDF.rb, it isn't, in itself, thread safe. The underlying data representation may be purely functional, but the Repository itself is swimming in shared mutable state. Specifically, we have the potential for a data race during execution of code like @data = data
; and, more generally, for race conditions wherever our changes depend on previous reads. Notably, this affects #transaction
, as demonstrated in the following snippet:
require 'rdf'
repo = RDF::Repository.new
threads = []
err_count = 0