Skip to content

Commit 3b7cc35

Browse files
rkondakovgvvinblade
authored andcommitted
IGNITE-7583: Secondary indexes xid_max support implemented.
1 parent dcf1d43 commit 3b7cc35

File tree

87 files changed

+1989
-1075
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1989
-1075
lines changed

modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/tree/BPlusTreeBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ protected static class TestTree extends BPlusTree<Long, Long> {
192192
}
193193

194194
/** {@inheritDoc} */
195-
@Override protected Long getRow(BPlusIO<Long> io, long pageAddr, int idx, Object ignore)
195+
@Override public Long getRow(BPlusIO<Long> io, long pageAddr, int idx, Object ignore)
196196
throws IgniteCheckedException {
197197
assert io.canGetRow() : io;
198198

modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/WALRecord.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public enum RecordType {
6363
/** */
6464
DATA_PAGE_SET_FREE_LIST_PAGE,
6565

66+
/** */
67+
MVCC_DATA_PAGE_MARK_UPDATED_RECORD,
68+
6669
/** */
6770
BTREE_META_PAGE_INIT_ROOT,
6871

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.internal.pagemem.wal.record.delta;
19+
20+
import org.apache.ignite.IgniteCheckedException;
21+
import org.apache.ignite.internal.pagemem.PageMemory;
22+
import org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO;
23+
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
24+
import org.apache.ignite.internal.util.typedef.internal.S;
25+
26+
/**
27+
* MVCC mark updated record.
28+
*/
29+
public class DataPageMvccMarkUpdatedRecord extends PageDeltaRecord {
30+
/** */
31+
private int itemId;
32+
33+
/** */
34+
private long newMvccCrd;
35+
36+
/** */
37+
private long newMvccCntr;
38+
39+
/**
40+
* @param grpId Cache group ID.
41+
* @param pageId Page ID.
42+
* @param itemId Item id.
43+
* @param newMvccCrd New MVCC coordinator version.
44+
* @param newMvccCntr New MVCC counter version.
45+
*/
46+
public DataPageMvccMarkUpdatedRecord(int grpId, long pageId, int itemId, long newMvccCrd, long newMvccCntr) {
47+
super(grpId, pageId);
48+
49+
this.itemId = itemId;
50+
this.newMvccCrd = newMvccCrd;
51+
this.newMvccCntr = newMvccCntr;
52+
}
53+
54+
/** {@inheritDoc} */
55+
@Override public void applyDelta(PageMemory pageMem, long pageAddr) throws IgniteCheckedException {
56+
DataPageIO io = PageIO.getPageIO(pageAddr);
57+
58+
io.markRemoved(pageAddr, itemId, pageMem.pageSize(), newMvccCrd, newMvccCntr);
59+
}
60+
61+
/** {@inheritDoc} */
62+
@Override public RecordType type() {
63+
return RecordType.MVCC_DATA_PAGE_MARK_UPDATED_RECORD;
64+
}
65+
66+
/**
67+
* @return Item id.
68+
*/
69+
public int itemId() {
70+
return itemId;
71+
}
72+
73+
/**
74+
* @return New MVCC coordinator version.
75+
*/
76+
public long newMvccCrd() {
77+
return newMvccCrd;
78+
}
79+
80+
/**
81+
* @return New MVCC counter version.
82+
*/
83+
public long newMvccCntr() {
84+
return newMvccCntr;
85+
}
86+
87+
/** {@inheritDoc} */
88+
@Override public String toString() {
89+
return S.toString(DataPageMvccMarkUpdatedRecord.class, this, "super", super.toString());
90+
}
91+
}

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,6 +3523,7 @@ private void loadEntry(KeyCacheObject key,
35233523
entry.initialValue(cacheVal,
35243524
ver,
35253525
null,
3526+
null,
35263527
ttl,
35273528
CU.EXPIRE_TIME_CALCULATE,
35283529
false,

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ public boolean tmLock(IgniteInternalTx tx,
662662
* @param val New value.
663663
* @param ver Version to use.
664664
* @param mvccVer Mvcc version.
665+
* @param newMvccVer New mvcc version.
665666
* @param ttl Time to live.
666667
* @param expireTime Expiration time.
667668
* @param preload Flag indicating whether entry is being preloaded.
@@ -675,6 +676,7 @@ public boolean tmLock(IgniteInternalTx tx,
675676
public boolean initialValue(CacheObject val,
676677
GridCacheVersion ver,
677678
@Nullable MvccVersion mvccVer,
679+
@Nullable MvccVersion newMvccVer,
678680
long ttl,
679681
long expireTime,
680682
boolean preload,

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,35 @@ public void mvccVersion(long crdVer, long ctr) {
8787
return 0;
8888
}
8989

90+
/**
91+
* @param newCrdVer New coordinator version.
92+
* @param newCtr New counter.
93+
*/
94+
public void newMvccVersion(long newCrdVer, long newCtr) {
95+
// No-op.
96+
}
97+
98+
/**
99+
* @return New MVCC version.
100+
*/
101+
public MvccVersion newMvccVersion() {
102+
return null;
103+
}
104+
105+
/**
106+
* @return new MVCC coordinator version.
107+
*/
108+
public long newCoordinatorVersion() {
109+
return 0;
110+
}
111+
112+
/**
113+
* @return new MVCC counter version.
114+
*/
115+
public long newCounter() {
116+
return 0;
117+
}
118+
90119
/**
91120
* @return Cache ID.
92121
*/

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ else if (tx.dht()) {
785785

786786
// Update indexes before actual write to entry.
787787
if (cctx.mvccEnabled())
788-
cctx.offheap().mvccInitialValue(this, ret, nextVer, expTime, null);
788+
cctx.offheap().mvccInitialValue(this, ret, nextVer, expTime, null, null);
789789
else
790790
storeValue(ret, expTime, nextVer, null);
791791

@@ -899,7 +899,7 @@ private EntryGetResult entryGetResult(CacheObject val, GridCacheVersion ver, boo
899899
// Update indexes.
900900
if (ret != null) {
901901
if (cctx.mvccEnabled())
902-
cctx.offheap().mvccInitialValue(this, ret, nextVer, expTime, null);
902+
cctx.offheap().mvccInitialValue(this, ret, nextVer, expTime, null, null);
903903
else
904904
storeValue(ret, expTime, nextVer, null);
905905

@@ -2747,6 +2747,7 @@ protected final boolean hasValueUnlocked() {
27472747
CacheObject val,
27482748
GridCacheVersion ver,
27492749
MvccVersion mvccVer,
2750+
MvccVersion newMvccVer,
27502751
long ttl,
27512752
long expireTime,
27522753
boolean preload,
@@ -2788,7 +2789,7 @@ protected final boolean hasValueUnlocked() {
27882789
val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);
27892790

27902791
if (cctx.mvccEnabled()) {
2791-
cctx.offheap().mvccInitialValue(this, val, ver, expTime, mvccVer);
2792+
cctx.offheap().mvccInitialValue(this, val, ver, expTime, mvccVer, newMvccVer);
27922793

27932794
if (val != null)
27942795
update(val, expTime, ttl, ver, true);
@@ -2972,7 +2973,7 @@ protected long nextPartitionCounter(AffinityTopologyVersion topVer, boolean prim
29722973

29732974
if (val != null) {
29742975
if (cctx.mvccEnabled())
2975-
cctx.offheap().mvccInitialValue(this, val, newVer, expTime, null);
2976+
cctx.offheap().mvccInitialValue(this, val, newVer, expTime, null, null);
29762977
else
29772978
storeValue(val, expTime, newVer, null);
29782979

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccEntryInfo.java

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
package org.apache.ignite.internal.processors.cache;
1919

2020
import java.nio.ByteBuffer;
21+
import org.apache.ignite.internal.processors.cache.mvcc.MvccVersion;
22+
import org.apache.ignite.internal.processors.cache.mvcc.MvccVersionImpl;
2123
import org.apache.ignite.internal.util.typedef.internal.S;
2224
import org.apache.ignite.plugin.extensions.communication.MessageReader;
2325
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -35,6 +37,12 @@ public class GridCacheMvccEntryInfo extends GridCacheEntryInfo {
3537
/** */
3638
private long mvccCntr;
3739

40+
/** */
41+
private long newMvccCrdVer;
42+
43+
/** */
44+
private long newMvccCntr;
45+
3846
/** {@inheritDoc} */
3947
@Override public void mvccVersion(long crdVer, long ctr) {
4048
this.mvccCrdVer = crdVer;
@@ -53,11 +61,32 @@ public class GridCacheMvccEntryInfo extends GridCacheEntryInfo {
5361

5462
/** {@inheritDoc} */
5563
@Override public byte fieldsCount() {
56-
return 8;
64+
return 10;
65+
}
66+
67+
/** {@inheritDoc} */
68+
@Override public void newMvccVersion(long newCrdVer, long newCtr) {
69+
this.newMvccCrdVer = newCrdVer;
70+
this.newMvccCntr = newCtr;
71+
}
72+
73+
/** {@inheritDoc} */
74+
public MvccVersion newMvccVersion() {
75+
return new MvccVersionImpl(newMvccCrdVer, newMvccCntr);
5776
}
5877

5978
/** {@inheritDoc} */
60-
@Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
79+
@Override public long newCoordinatorVersion() {
80+
return newMvccCrdVer;
81+
}
82+
83+
/** {@inheritDoc} */
84+
@Override public long newCounter() {
85+
return newMvccCntr;
86+
}
87+
88+
/** {@inheritDoc} */
89+
public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
6190
writer.setBuffer(buf);
6291

6392
if (!super.writeTo(buf, writer))
@@ -83,6 +112,17 @@ public class GridCacheMvccEntryInfo extends GridCacheEntryInfo {
83112

84113
writer.incrementState();
85114

115+
case 8:
116+
if (!writer.writeLong("newMvccCntr", newMvccCntr))
117+
return false;
118+
119+
writer.incrementState();
120+
121+
case 9:
122+
if (!writer.writeLong("newMvccCrdVer", newMvccCrdVer))
123+
return false;
124+
125+
writer.incrementState();
86126
}
87127

88128
return true;
@@ -115,6 +155,22 @@ public class GridCacheMvccEntryInfo extends GridCacheEntryInfo {
115155

116156
reader.incrementState();
117157

158+
case 8:
159+
newMvccCntr = reader.readLong("newMvccCntr");
160+
161+
if (!reader.isLastRead())
162+
return false;
163+
164+
reader.incrementState();
165+
166+
case 9:
167+
newMvccCrdVer = reader.readLong("newMvccCrdVer");
168+
169+
if (!reader.isLastRead())
170+
return false;
171+
172+
reader.incrementState();
173+
118174
}
119175

120176
return reader.afterMessageRead(GridCacheMvccEntryInfo.class);

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,7 @@ private void process(KeyCacheObject key, CacheObject val, GridCacheVersion ver,
17891789
val,
17901790
ver,
17911791
null,
1792+
null,
17921793
expiryPlc == null ? 0 : expiryPlc.forCreate(),
17931794
expiryPlc == null ? 0 : toExpireTime(expiryPlc.forCreate()),
17941795
false,

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ public List<T2<Object, MvccVersion>> mvccAllVersions(GridCacheContext cctx, KeyC
202202
* @param val Value.
203203
* @param ver Version.
204204
* @param mvccVer MVCC version.
205+
* @param newMvccVer New MVCC version.
205206
* @return {@code True} if value was inserted.
206207
* @throws IgniteCheckedException If failed.
207208
*/
@@ -210,7 +211,8 @@ public boolean mvccInitialValue(
210211
@Nullable CacheObject val,
211212
GridCacheVersion ver,
212213
long expireTime,
213-
MvccVersion mvccVer
214+
MvccVersion mvccVer,
215+
MvccVersion newMvccVer
214216
) throws IgniteCheckedException;
215217

216218
/**
@@ -542,6 +544,7 @@ void update(
542544
* @param val Value.
543545
* @param ver Version.
544546
* @param mvccVer MVCC version.
547+
* @param newMvccVer New MVCC version.
545548
* @return {@code True} if new value was inserted.
546549
* @throws IgniteCheckedException If failed.
547550
*/
@@ -551,7 +554,8 @@ boolean mvccInitialValue(
551554
@Nullable CacheObject val,
552555
GridCacheVersion ver,
553556
long expireTime,
554-
MvccVersion mvccVer) throws IgniteCheckedException;
557+
MvccVersion mvccVer,
558+
MvccVersion newMvccVer) throws IgniteCheckedException;
555559

556560
/**
557561
* @param cctx Cache context.

0 commit comments

Comments
 (0)