Atomic replacement of documents with a collection
Tuesday, 1 August 2017 · 3 messages
AJ
Andreas Jung1 Aug 2017 11:34 #
Hi there,
I am finally heading for the first time to use BaseX in a customer project. We need to import XML based product catalogs in different languages. The catalog files should be updated each night without service interruption. What is the best strategy to update and replace an existing document without race condition? Should I uploaded the new version of a catalog under a different filename first and then use REPLACE? Is REPLACE atomic in the sense that an ongoing request will see the „old“ state of the document and new requests will see the new state of the document without any undefined state in between?
Andreas
CG
Christian Grün1 Aug 2017 11:45 #
Hi Andreas,
Quoted text · Andreas Jung · 3 lines
> Is REPLACE atomic in the sense that an > ongoing request will see the „old“ state of the document and new requests will > see the new state of the document without any undefined state in between?
The transaction manager of BaseX guarantees that there will be no conflicting requests on updated documents (see [1] for more details), so you’ll be safe when using REPLACE.
Quoted text · Andreas Jung · 2 lines
> Should I uploaded the new version of a catalog under a different > filename first and then use REPLACE?
This mostly depends on how you use BaseX: If you use our HTTP services (e.g. the PUT method with REST, which is comparable to executing REPLACE), everything could be done in a single step. If you use a separate web server, and only use the client/server architecture of BaseX, uploading the file first may be a good idea.
Feel free to tell us more about your architecture,
Christian
[1] http://docs.basex.org/wiki/Transaction_Management
AJ
Andreas Jung1 Aug 2017 11:52 #
Thanks Christian,
sound all good to me.
Andreas
Quoted text · Christian Grün · 24 lines
On 1 Aug 2017, at 11:45, Christian Grün wrote: > Hi Andreas, > >> Is REPLACE atomic in the sense that an >> ongoing request will see the „old“ state of the document and new requests will >> see the new state of the document without any undefined state in between? > > The transaction manager of BaseX guarantees that there will be no > conflicting requests on updated documents (see [1] for more details), > so you’ll be safe when using REPLACE. > >> Should I uploaded the new version of a catalog under a different >> filename first and then use REPLACE? > > This mostly depends on how you use BaseX: If you use our HTTP services > (e.g. the PUT method with REST, which is comparable to executing > REPLACE), everything could be done in a single step. If you use a > separate web server, and only use the client/server architecture of > BaseX, uploading the file first may be a good idea. > > Feel free to tell us more about your architecture, > Christian > > [1] http://docs.basex.org/wiki/Transaction_Management
Written for BaseX 8.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery