15.07.2016 Views

MARKLOGIC SERVER

Inside-MarkLogic-Server

Inside-MarkLogic-Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

MarkLogic starts by parsing and indexing the document contents, converting the<br />

document from serialized XML to a compressed binary fragment representation of<br />

the XML data model (strictly, the XQuery Data Model 9 ). The fragment is added to the<br />

in-memory stand. At this point, the fragment is considered a nascent fragment—a term<br />

you'll see sometimes on the Admin Interface status pages. Being nascent means it exists<br />

in a stand but hasn't been fully committed. (On a technical level, nascent fragments'<br />

creation and deletion timestamps are both set to infinity, so they can be managed by the<br />

system while not appearing in queries prematurely.) If you're doing a large transactional<br />

insert, you'll accumulate a lot of nascent fragments while the documents are being<br />

processed. They stay nascent until they've been committed.<br />

At some point, our statement completes successfully, and the request is ready to<br />

commit. MarkLogic obtains the next timestamp value, journals its intent to commit<br />

the transaction, and then makes the fragment available by setting the creation<br />

timestamp for the new fragment to the transaction's timestamp. At this point, it's a<br />

durable transaction, replayable in the event of server failure, and it's available to any<br />

new queries that run at this timestamp or later, as well as any updates from this point<br />

forward (even those in progress). As the request terminates, the write lock gets released.<br />

Our document lives for a time in the in-memory stand, fully queryable and durable,<br />

until at some point, the in-memory stand fills up and is written to disk. Our document is<br />

now in an on-disk stand.<br />

Sometime later, based on merge algorithms, the on-disk stand will get merged with<br />

some other on-disk stands to produce a new on-disk stand. The fragment will be carried<br />

over, its tree data and indexes incorporated into the larger stand. This might happen<br />

several times.<br />

At some point, a new request makes a change to the document, such as with an<br />

xdmp:node-replace() call. The request making the change obtains a read lock on<br />

the URI when it first accesses the document, then promotes the read lock to a write lock<br />

when executing the xdmp:node-replace() call. If another write lock were already<br />

present on the URI from another executing update, the read lock would have blocked<br />

until the other write lock released. If another read-lock were already present, the lock<br />

promotion to a write lock would have blocked.<br />

Assuming that the update request finishes successfully, the work runs similar to before:<br />

parsing and indexing the document, writing it to the in-memory stand as a nascent<br />

fragment, acquiring a timestamp, journaling the work, and setting the creation<br />

9 The data model is defined in exhaustive detail at XQuery and XPath Data Model and may differ from the<br />

serialized format in many ways. For example, when serialized in XML, an attribute value may be surrounded<br />

by single or double quotes. In the data model, that difference is not recorded.<br />

42

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!