Information Technology Reference
In-Depth Information
will not be X-locked. Second, of two different fragments g
i
.x/ and g
i
.y/ with i<
m, the one containing more g
iC1
-fragments is more suitable for X-locking than the
other.
We apply the relaxed key-range locking protocol discussed in Problem
9.3
.
According to this protocol, the short-duration lock to be acquired on the next key is
only an IX lock instead of an X lock.
Example 10.10
In the case of the bulk-insert action
insert into
sales
select
from
sales-2015-09-25-S123
order by
sales-date
,
store-id
,
item-id
,
the query for the g
3
partition is
insert into
temp-sales-2015-09-25-S123
3
select
year(sales-date)
,
month(sales-date)
,
day(sales-date)
,
store-id
,
count
(
)
from
sales-2015-09-25-S123
group by
year(sales-date)
,
month(sales-date)
,
day(sales-date)
,
store-id
,
which will reveal that the tuples to be inserted all belong to a single g
3
-fragment
(
sales
, 2015, 9, 25, S123) and that there are 1,000 such tuples. Thus, commit-
duration IX locks are acquired on the
sales
table and the fragments (
sales
, 2015, 3)
and (
sales
, 2015, 9, 25), and a commit-duration X lock is acquired on the fragment
(
sales
, 2015, 9, 25, S123). The only locks that remain to be acquired during the
actual insertion are the short-duration IX lock on the key of the
sales
tuple next
to the last tuple inserted and the IX locks on the fragments containing this next
tuple.
t
In the general case, a bulk-insert action X-locks for commit duration a sequence
of fragments and IX-locks for commit duration the containing fragments, where the
X-locked fragments together cover the keys of the tuples to be inserted. In addition
to these locks, in order to follow the principle of key-range locking, the key of every
existing tuple next to an inserted tuple that is not covered by an X-locked fragment
must be IX-locked for short duration, and the containing fragments must be IX-
locked for commit duration. All these locks are acquired in ascending key order
during a left-to-right scan of the insertion points of the tuples to be inserted.
A bulk-delete action DŒs
X
;s
XV
with Œ
z
1
;
z
2
2
s
X
must X-lock for short duration
the smallest partition fragment that covers the keys
z
1
and
z
2
and to IX-lock for short
duration the containing fragments. In other words, when
k
D
max
f
i
j
0
i
m; g
i
.
z
1
/
D
g
i
.
z
2
/
g
;
the fragments g
0
.
z
1
/; g
1
.
z
1
/;:::;g
k1
.
z
1
/ are IX-locked and the fragment g
k
.
z
1
/
is X-locked. Moreover, following the principle of key-range locking, a commit-
duration X-lock must be acquired on the key of the tuple next to the last deleted
tuple in the range Œ
z
1
;
z
2
, and commit-duration IX locks must be acquired on the
containing fragments.