Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
312e76d
ignite-11704
sboikov1983 Jul 9, 2019
345a7a5
Merge remote-tracking branch 'remotes/origin/master' into ignite-11704
sboikov1983 Jul 10, 2019
d5e4e78
ignite-11704
sboikov1983 Jul 10, 2019
4403455
ignite-11704
sboikov1983 Jul 10, 2019
5a05291
ignite-11704
sboikov1983 Jul 11, 2019
e6a793b
ignite-11704
sboikov1983 Jul 19, 2019
2a0a0e0
ignite-11704
sboikov1983 Jul 19, 2019
8c9bd4f
Merge remote-tracking branch 'origin/ignite-11704' into ignite-11704
sboikov1983 Jul 21, 2019
a5ef55f
ignite-11704
sboikov1983 Jul 23, 2019
86bc43e
ignite-11704
sboikov1983 Jul 23, 2019
0a574a6
ignite-11704
sboikov1983 Jul 23, 2019
db16252
ignite-11704
sboikov1983 Jul 24, 2019
1779d38
Merge remote-tracking branch 'remotes/origin/master' into ignite-11704
sboikov1983 Jul 26, 2019
08b59dd
ignite-11704
sboikov1983 Jul 26, 2019
8294495
ignite-11704
sboikov1983 Jul 26, 2019
3435978
Merge remote-tracking branch 'remotes/origin/master' into ignite-11704
sboikov1983 Jul 28, 2019
8299a2c
ignite-11704
sboikov1983 Jul 28, 2019
10d24bd
ignite-11704
sboikov1983 Jul 30, 2019
5010c38
ignite-11704
sboikov1983 Jul 30, 2019
8035686
ignite-11704
sboikov1983 Jul 30, 2019
ea425b4
ignite-11704
sboikov1983 Jul 30, 2019
7d3fcdc
ignite-11704
sboikov1983 Jul 30, 2019
901661a
ignite-11704
sboikov1983 Jul 30, 2019
546299e
Merge remote-tracking branch 'remotes/origin/master' into ignite-11704
sboikov1983 Jul 30, 2019
a6cd27d
ignite-11704
sboikov1983 Jul 31, 2019
b4e5941
Merge remote-tracking branch 'remotes/origin/master' into ignite-11704
sboikov1983 Jul 31, 2019
1da9dc3
ignite-11704
sboikov1983 Aug 1, 2019
ddd8e13
Merge branch 'master' into ignite-11704
Jokser Sep 25, 2019
ee2dded
IGNITE-11704 Cleanup
Jokser Sep 25, 2019
cf4486e
IGNITE-11704 Cleanup
Jokser Sep 27, 2019
291883a
Merge branch 'master' into ignite-11704
Jokser Oct 1, 2019
0f45850
IGNITE-11704 Failover for tombstones.
Jokser Oct 2, 2019
da4c092
IGNITE-11704 Missed docs.
Jokser Oct 2, 2019
81eab42
IGNITE-11704 Fixed imports.
Jokser Oct 3, 2019
12baf1b
IGNITE-11704 Remove assertion during remove with tombstone and tests …
Jokser Oct 3, 2019
24822ca
Merge branch 'master' into ignite-11704
Jokser Oct 14, 2019
027370d
IGNITE-11704 Track suspicious update version in initialValue.
Jokser Oct 14, 2019
d083b95
IGNITE-11704 Tombstone storing is optimized.
Jokser Oct 15, 2019
9ce450e
Merge branch 'master' into ignite-11704
Jokser Oct 15, 2019
919745d
IGNITE-11704 Avoid code duplication in clearAll and clearTombstones.
Jokser Oct 15, 2019
0babc69
IGNITE-11704 Enhanced tombstone with historical rebalance test.
Jokser Oct 16, 2019
307800a
Merge branch 'master' into ignite-11704
Jokser Oct 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.ignite.internal.processors.cache.GridCacheReturn;
import org.apache.ignite.internal.processors.cache.GridChangeGlobalStateMessageResponse;
import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl;
import org.apache.ignite.internal.processors.cache.TombstoneCacheObject;
import org.apache.ignite.internal.processors.cache.WalStateAckMessage;
import org.apache.ignite.internal.processors.cache.binary.MetadataRequestMessage;
import org.apache.ignite.internal.processors.cache.binary.MetadataResponseMessage;
Expand Down Expand Up @@ -1166,6 +1167,11 @@ public GridIoMessageFactory(MessageFactory[] ext) {

break;

case 176:
msg = TombstoneCacheObject.INSTANCE;

break;

// [-3..119] [124..129] [-23..-28] [-36..-55] - this
// [120..123] - DR
// [-4..-22, -30..-35] - SQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public static int getUnsignedByte(long addr, int off) {
*/
public static byte[] getBytes(long addr, int off, int len) {
assert addr > 0 : addr;
assert off >= 0;
assert len >= 0;
assert off >= 0 : off;
assert len >= 0 : len;

byte[] bytes = new byte[len];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,11 @@ public enum RecordType {
/** Rollback tx record. */
ROLLBACK_TX_RECORD (57, LOGICAL),

/** */
PARTITION_META_PAGE_UPDATE_COUNTERS_V2 (58, PHYSICAL);
/** Partition meta page containing update counter gaps. */
PARTITION_META_PAGE_UPDATE_COUNTERS_V2 (58, PHYSICAL),

/** Partition meta page containing tombstone presence flag. */
PARTITION_META_PAGE_UPDATE_COUNTERS_V3 (59, PHYSICAL);

/** Index for serialization. Should be consistent throughout all versions. */
private final int idx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class MetaPageUpdatePartitionDataRecord extends PageDeltaRecord {
private int allocatedIdxCandidate;

/** */
private long cntrsPageId;
private long cacheSizesPageId;

/**
* @param grpId Cache group ID.
Expand All @@ -59,17 +59,18 @@ public MetaPageUpdatePartitionDataRecord(
long updateCntr,
long globalRmvId,
int partSize,
long cntrsPageId,
long cacheSizesPageId,
byte state,
int allocatedIdxCandidate) {
int allocatedIdxCandidate
) {
super(grpId, pageId);

this.updateCntr = updateCntr;
this.globalRmvId = globalRmvId;
this.partSize = partSize;
this.state = state;
this.allocatedIdxCandidate = allocatedIdxCandidate;
this.cntrsPageId = cntrsPageId;
this.cacheSizesPageId = cacheSizesPageId;
}

/**
Expand All @@ -81,7 +82,7 @@ public MetaPageUpdatePartitionDataRecord(DataInput in) throws IOException{
this.updateCntr = in.readLong();
this.globalRmvId = in.readLong();
this.partSize = in.readInt();
this.cntrsPageId = in.readLong();
this.cacheSizesPageId = in.readLong();
this.state = in.readByte();
this.allocatedIdxCandidate = in.readInt();
}
Expand Down Expand Up @@ -110,8 +111,8 @@ public int partitionSize() {
/**
* @return Partition size.
*/
public long countersPageId() {
return cntrsPageId;
public long cacheSizesPageId() {
return cacheSizesPageId;
}

/**
Expand All @@ -128,7 +129,7 @@ public byte state() {
io.setUpdateCounter(pageAddr, updateCntr);
io.setGlobalRemoveId(pageAddr, globalRmvId);
io.setSize(pageAddr, partSize);
io.setCountersPageId(pageAddr, cntrsPageId);
io.setSizesPageId(pageAddr, cacheSizesPageId);
io.setPartitionState(pageAddr, state);
io.setCandidatePageCount(pageAddr, allocatedIdxCandidate);
}
Expand All @@ -150,7 +151,7 @@ public void toBytes(ByteBuffer buf) {
buf.putLong(updateCounter());
buf.putLong(globalRemoveId());
buf.putInt(partitionSize());
buf.putLong(countersPageId());
buf.putLong(cacheSizesPageId());
buf.put(state());
buf.putInt(allocatedIndexCandidate());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
import org.apache.ignite.internal.util.typedef.internal.S;

/**
*
* Partition meta page delta record.
* Contains reference to update counters gaps.
*/
public class MetaPageUpdatePartitionDataRecordV2 extends MetaPageUpdatePartitionDataRecord {
/** */
private long link;
private long gapsLink;

/**
* @param grpId Group id.
Expand All @@ -43,7 +44,7 @@ public class MetaPageUpdatePartitionDataRecordV2 extends MetaPageUpdatePartition
* @param cntrsPageId Cntrs page id.
* @param state State.
* @param allocatedIdxCandidate Allocated index candidate.
* @param link Link.
* @param gapsLink Link.
*/
public MetaPageUpdatePartitionDataRecordV2(
int grpId,
Expand All @@ -54,9 +55,10 @@ public MetaPageUpdatePartitionDataRecordV2(
long cntrsPageId,
byte state,
int allocatedIdxCandidate,
long link) {
long gapsLink
) {
super(grpId, pageId, updateCntr, globalRmvId, partSize, cntrsPageId, state, allocatedIdxCandidate);
this.link = link;
this.gapsLink = gapsLink;
}

/**
Expand All @@ -65,7 +67,7 @@ public MetaPageUpdatePartitionDataRecordV2(
public MetaPageUpdatePartitionDataRecordV2(DataInput in) throws IOException {
super(in);

this.link = in.readLong();
this.gapsLink = in.readLong();
}

/** {@inheritDoc} */
Expand All @@ -74,21 +76,21 @@ public MetaPageUpdatePartitionDataRecordV2(DataInput in) throws IOException {

PagePartitionMetaIOV2 io = (PagePartitionMetaIOV2)PagePartitionMetaIO.VERSIONS.forPage(pageAddr);

io.setGapsLink(pageAddr, link);
io.setGapsLink(pageAddr, gapsLink);
}

/**
*
*/
public long link() {
return link;
public long gapsLink() {
return gapsLink;
}

/** {@inheritDoc} */
@Override public void toBytes(ByteBuffer buf) {
super.toBytes(buf);

buf.putLong(link());
buf.putLong(gapsLink());
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.internal.pagemem.wal.record.delta;

import java.io.DataInput;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.pagemem.PageIdUtils;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIO;
import org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIOV2;
import org.apache.ignite.internal.util.typedef.internal.S;

/**
* Partition meta page delta record.
* Contains information about tombstones count.
*/
public class MetaPageUpdatePartitionDataRecordV3 extends MetaPageUpdatePartitionDataRecordV2 {
/** Tombstones count. */
private long tombstonesCnt;

/**
* @param grpId Group id.
* @param pageId Page id.
* @param updateCntr Update counter.
* @param globalRmvId Global remove id.
* @param partSize Partition size.
* @param cacheSizesPageId Cache sizes page id.
* @param state State.
* @param allocatedIdxCandidate Allocated index candidate.
* @param gapsLink Gaps link.
* @param tombstonesCnt Tombstones count.
*/
public MetaPageUpdatePartitionDataRecordV3(
int grpId,
long pageId,
long updateCntr,
long globalRmvId,
int partSize,
long cacheSizesPageId,
byte state,
int allocatedIdxCandidate,
long gapsLink,
long tombstonesCnt
) {
super(grpId, pageId, updateCntr, globalRmvId, partSize, cacheSizesPageId, state, allocatedIdxCandidate, gapsLink);
this.tombstonesCnt = tombstonesCnt;
}

/**
* @param in In.
*/
public MetaPageUpdatePartitionDataRecordV3(DataInput in) throws IOException {
super(in);

this.tombstonesCnt = in.readLong();
}

/**
* @return Tombstones count.
*/
public long tombstonesCount() {
return tombstonesCnt;
}

/** {@inheritDoc} */
@Override public void applyDelta(PageMemory pageMem, long pageAddr) throws IgniteCheckedException {
super.applyDelta(pageMem, pageAddr);

PagePartitionMetaIOV2 io = (PagePartitionMetaIOV2) PagePartitionMetaIO.VERSIONS.forPage(pageAddr);

io.setTombstonesCount(pageAddr, tombstonesCnt);
}

/** {@inheritDoc} */
@Override public void toBytes(ByteBuffer buf) {
super.toBytes(buf);

buf.putLong(tombstonesCnt);
}

/** {@inheritDoc} */
@Override public RecordType type() {
return RecordType.PARTITION_META_PAGE_UPDATE_COUNTERS_V3;
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(MetaPageUpdatePartitionDataRecordV2.class, this, "partId", PageIdUtils.partId(pageId()),
"super", super.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentRequest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopologyImpl;
import org.apache.ignite.internal.processors.cache.persistence.DataRegion;
Expand Down Expand Up @@ -261,6 +263,8 @@ public class CacheGroupContext {
statHolderIdx = new IoStatisticsHolderIndex(HASH_INDEX, cacheOrGroupName(), HASH_PK_IDX_NAME, mmgr);
statHolderData = new IoStatisticsHolderCache(cacheOrGroupName(), grpId, mmgr);
}

hasAtomicCaches = ccfg.getAtomicityMode() == ATOMIC;
}

/**
Expand Down Expand Up @@ -1298,6 +1302,21 @@ public boolean hasAtomicCaches() {
return hasAtomicCaches;
}

/**
* @return {@code True} if need create temporary tombstones entries for removed data.
*/
public boolean supportsTombstone() {
return !mvccEnabled && !isLocal();
}

/**
* @param part Partition.
* @return {@code True} if need create tombstone for remove in given partition.
*/
public boolean shouldCreateTombstone(@Nullable GridDhtLocalPartition part) {
return part != null && supportsTombstone() && part.state() == GridDhtPartitionState.MOVING;
}

/**
* @return Metrics.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class CacheGroupMetricsImpl {
private final LongMetric sparseStorageSize;

/** Interface describing a predicate of two integers. */
@FunctionalInterface
private interface IntBiPredicate {
/**
* Predicate body.
Expand Down Expand Up @@ -169,6 +170,10 @@ public void onTopologyInitialized() {
mreg.register("TotalAllocatedSize",
this::getTotalAllocatedSize,
"Total size of memory allocated for group, in bytes.");

mreg.register("Tombstones",
this::getTombstones,
"Number of tombstone entries.");
}

/** */
Expand Down Expand Up @@ -253,20 +258,12 @@ private int numberOfPartitionCopies(IntBiPredicate pred) {

/** */
public int getMinimumNumberOfPartitionCopies() {
return numberOfPartitionCopies(new IntBiPredicate() {
@Override public boolean apply(int targetVal, int nextVal) {
return nextVal < targetVal;
}
});
return numberOfPartitionCopies((targetVal, nextVal) -> nextVal < targetVal);
}

/** */
public int getMaximumNumberOfPartitionCopies() {
return numberOfPartitionCopies(new IntBiPredicate() {
@Override public boolean apply(int targetVal, int nextVal) {
return nextVal > targetVal;
}
});
return numberOfPartitionCopies((targetVal, nextVal) -> nextVal > targetVal);
}

/**
Expand Down Expand Up @@ -462,6 +459,12 @@ public long getSparseStorageSize() {
return sparseStorageSize == null ? 0 : sparseStorageSize.value();
}

/** */
public long getTombstones() {
return ctx.topology().localPartitions().stream()
.map(part -> part.dataStore().tombstonesCount()).reduce(Long::sum).orElse(0L);
}

/** Removes all metric for cache group. */
public void remove() {
ctx.shared().kernalContext().metric().remove(metricGroupName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public interface CacheObject extends Message {
/** */
public static final byte TYPE_BINARY_ENUM = 101;

/** */
public static final byte TOMBSTONE = -1;

/**
* @param ctx Context.
* @param cpy If {@code true} need to copy value.
Expand Down
Loading