Programación I y Laboratorio 3 créditos
ECON301 Economía
Recall from Figure 4.3 on page 68 the problem of inserting multiple data- item entries into the MVBT index with the same version. When per- forming a version-split operation on page p, a new copy p′ of the page is
created and the life span of the original page p is truncated to the cur- rent version and the page is left as it is for use in historical queries. If the page p was created by the same transaction that triggers the version split, the life span of the page will degenerate into an empty range, and the page will thus not be part of any search tree in the database. In these situations, the key split can be performed directly on the page p, without applying the version-split operation first.
Let us now define the concepts of active entries and active pages to classify the situations where a version-split operation is not required and in fact must not be performed. Remember that the single updating trans- action always has the version vactive as its identifier and uses that version
to stamp the data-item updates and structure-modification operations. Definition 5.1. An active entry (or active page, respectively) in the TMVBT index is an entry (page) that has a life span of [vactive,∞). An
active entry (page) has been created earlier on by the same updating transaction. Entries (pages) that are not active are called inactive entries
(inactive pages). ◻
As stated in the previous chapter, read-only transactions may only read versions that have a commit-time version of at most vcommit. This
leads to the following observation:
Invariant 5.2. Read-only transactions in the TMVBT index only read inactive entries and pages. Active entries and pages are only seen by the single active updating transaction.
If the active updating transaction is deleting an active entry, the entry can be physically removed from the index, instead of changing its life span. This does not invalidate partial persistence, because the active entry was created by the same transaction, and thus did not exist before
5.2 Active Entries
the updating transaction first inserted it. Updates that are internal to the transaction are not visible outside the transaction and must not consume space in the index.
Invariant 5.3. When a single updating transaction T deletes an active entry (created by T ), the entry is physically removed from the TMVBT index. Similarly, if T updates an active entry it physically removes the old entry and creates a new active entry to replace the old one.
When performing a version-split operation on a page p at version v in the original MVBT index, Becker et al. suggested that the entries that are left in page p may be left unmodified [8], so that the life spans of the entries ei that were alive at version v remain unbounded on the above;
that is, of the form[vi,∞), where vi< v. This does not affect any queries,
because only historical queries targeting versions v′< v will ever end up in
the historical page p; thus, even if an entry ei is deleted by a transaction
with a version v′′> v, the queries targeting those newer versions will never
encounter the now-outdated entry ei on the historical page p. However, if
a transaction T stores a previously used path as a saved path (see p. 91) and reuses the path later on, it is possible that the pages in the saved path are no longer valid. The transaction T cannot ascertain the validity of the pages unless the consistency of the life spans of all the entries and pages is maintained, so that the deletion times of entries in historical pages are set to the deletion time of the historical page. In the TMVBT index, we explicitly require that the life spans of entries that are left on a historical page are cropped so that they end at the version during which the page was split:
Invariant 5.4. When a page p in the TMVBT index is version-split into a new page p′ at version v
active, all live entries (k, [v, ∞), w) such
that v < vactive are processed as follows: a live copy (k, [vactive,∞), w) is
created and inserted into the new live page p′, and the live entry at page p
is changed to the historical entry (k, [v, vactive), w). All active live entries
of the form (k, [vactive,∞), w) are physically moved to the new page p′.
This invariant is required in order that the key-version regions of all the entries of a given level of the TMVBT index do not overlap, as shown in Figure 4.2 on page 63. By adhering to these rules, we can also obtain the following lemmata:
Lemma 5.1. Active pages in the TMVBT only contain active entries. Proof. An active page is a page that was created by the active updat- ing transaction. When the transaction commits, the page immediately
becomes inactive. When an active page p was created, all the live en- tries that were copied to it were changed so that their life spans start at the split boundary (i.e., at version vactive), thus making the copies of the
entries active. If the active entries are changed in any way by the same transaction, they will be physically deleted or replaced by new active
entries, as per Invariant 5.3. ◻
Lemma 5.2. Active pages have at most one parent.
Proof. Multiple parents in a multiversion index are caused by multiple routers to the same page p in the index pages above the page p. When an active page p is created, a new index entry ip is inserted to the parent
page p′. Note that the index entry i
p is also active, and will remain
active until the current active transaction commits. When the current transaction commits, both the entry ip and the page p will immediately
become inactive. By Invariant 5.4, active entries are physically moved during a version-split operation. If the parent page p′ is version-split
before the active transaction commits, the index entry ip is physically
moved to the new page, thereby preventing the creation of new copies of ip. Because there can be only a single index entry ip pointing to an
active page p, active pages can only have a single parent. ◻
All the entries of active TMVBT pages have the same life span of [vactive,∞). This holds for both leaf pages and index pages, and is illus-
trated in Figure 5.1. Because of this fact, we can in fact disregard the life spans of entries when performing an operation on active pages: in effect, we can treat active pages as if they were pages in a non-versioned B+-tree
index. The extended TMVBT algorithms are based on this observation. The algorithms themselves are explained in detail in Section 5.5.
For an example, let us review the problem scenario in MVBT as de- picted in Figure 4.3 on page 68. In the TMVBT, the page p1 is active,
and thus it can be key-split directly without version-splitting it first. The operation of the same transaction, executing on the TMVBT index, is shown in Figure 5.2.