I have been converting my code from using TDB-backed models without transactions to using TDB-backed models with transactions. Without transactions, as far as I understand (also from this mailing list post) that without transactions, after modifying the dataset it is necessary to call model.close() in order to ensure that dataset is synced correctly and that automatically does dataset.sync().
I have noticed that there are two sets of methods for controlling transactions:
dataset.begin() and dataset.commit(), etc
model.begin() and model.commit(), etc
What is the difference between these two sets of methods? Does calling model.commit() do the equivalent of dataset.commit() in the same way that model.close() automatically takes care of dataset.sync()?
I hope this is clear
model.commit()is the old interface designed when models where a unit of storage, before RDF datasets were invented in SPARQL.dataset.begintakes a read/write flag.dataset.begin(ReadWrite.READ). By knowing it’s a read transaction the system can proceed much more efficiently (no admin for potential writes later) and also there are no issues with locking (two transactions each trying to start a write operation when they have made reads to the others view).TDB transactions are fully serializable and work at the dataset level.
TDB transactions allows writers to start when old read transactions are still active, for any depth of new writer having commited since the read transactions started. Different transactions see different states of the database, each state is consistent. There are no dirty reads.