Skip to content

Commit ba46655

Browse files
committed
Big objects bug fix.
1 parent 13431b8 commit ba46655

2 files changed

Lines changed: 32 additions & 45 deletions

File tree

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/AbstractFreeList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ else if (PageIdUtils.tag(pageId) != PageIdAllocator.FLAG_DATA)
756756
int written;
757757

758758
if (dataRows.size() == 1) {
759-
written = fragment ? row.size() - (rows.size() % maxPayloadSize) : 0;
759+
written = fragment ? row.size() - (row.size() % maxPayloadSize) : 0;
760760

761761
written = write(pageId, writeRows, initIo, row, written, FAIL_I, statHolder);
762762
} else

modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListPreloadWithBatchUpdatesTest.java

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.apache.ignite.internal.util.typedef.PA;
4242
import org.apache.ignite.internal.util.typedef.internal.U;
4343
import org.apache.ignite.testframework.GridTestUtils;
44+
import org.apache.ignite.testframework.junits.WithSystemProperty;
4445
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
4546
import org.junit.After;
4647
import org.junit.Before;
@@ -62,7 +63,10 @@ public class FreeListPreloadWithBatchUpdatesTest extends GridCommonAbstractTest
6263
private static final int HDR_SIZE = 8 + 32;
6364

6465
/** */
65-
private static final long DEF_REG_SIZE = 6 * 1024 * 1024 * 1024L;
66+
private static final long DEF_REG_SIZE_INIT = 3400 * 1024 * 1024L;
67+
68+
/** */
69+
private static final long DEF_REG_SIZE = 6144 * 1024 * 1024L;
6670

6771
/** */
6872
private static final String DEF_CACHE_NAME = "some-cache";
@@ -73,15 +77,15 @@ public static Iterable<Object[]> setup() {
7377
return Arrays.asList(new Object[][]{
7478
{CacheAtomicityMode.ATOMIC, false},
7579
{CacheAtomicityMode.ATOMIC, true},
76-
// {CacheAtomicityMode.TRANSACTIONAL, false},
77-
// {CacheAtomicityMode.TRANSACTIONAL, true},
78-
// {CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, false},
79-
// {CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, true}
80+
{CacheAtomicityMode.TRANSACTIONAL, false},
81+
{CacheAtomicityMode.TRANSACTIONAL, true},
82+
{CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, false},
83+
{CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT, true}
8084
});
8185
}
8286

8387
/** */
84-
@Parameterized.Parameter(0)
88+
@Parameterized.Parameter()
8589
public CacheAtomicityMode cacheAtomicityMode;
8690

8791
/** */
@@ -93,7 +97,7 @@ public static Iterable<Object[]> setup() {
9397
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
9498

9599
DataRegionConfiguration def = new DataRegionConfiguration();
96-
def.setInitialSize(3400 * 1024 * 1024L);
100+
def.setInitialSize(DEF_REG_SIZE_INIT);
97101
def.setMaxSize(DEF_REG_SIZE);
98102
def.setPersistenceEnabled(persistence);
99103

@@ -117,8 +121,6 @@ public static Iterable<Object[]> setup() {
117121
@Before
118122
public void before() throws Exception {
119123
cleanPersistenceDir();
120-
121-
System.setProperty(IGNITE_DATA_STORAGE_BATCH_PAGE_WRITE, "true");
122124
}
123125

124126
/**
@@ -129,15 +131,13 @@ public void after() throws Exception {
129131
stopAllGrids();
130132

131133
cleanPersistenceDir();
132-
133-
System.clearProperty(IGNITE_PDS_WAL_REBALANCE_THRESHOLD);
134-
System.clearProperty(IGNITE_DATA_STORAGE_BATCH_PAGE_WRITE);
135134
}
136135

137136
/**
138137
*
139138
*/
140139
@Test
140+
@WithSystemProperty(key = IGNITE_DATA_STORAGE_BATCH_PAGE_WRITE, value = "true")
141141
public void testBatchRebalance() throws Exception {
142142
Ignite node = startGrid(0);
143143

@@ -148,16 +148,14 @@ public void testBatchRebalance() throws Exception {
148148
node.createCache(ccfg());
149149

150150
int cnt = 100_000;
151-
int minSize = 0;
152-
int maxSize = 2048;
153-
int start = 0;
154151

155-
log.info("Loading " + cnt + " random entries per " + minSize + " - " + maxSize + " bytes.");
152+
int minSize = 0;
153+
int maxSize = 16384;
156154

157155
Map<Integer, byte[]> srcMap = new HashMap<>();
158156

159-
for (int i = start; i < start + cnt; i++) {
160-
int size = minSize + ThreadLocalRandom.current().nextInt(maxSize - minSize);
157+
for (int i = 0; i < cnt; i++) {
158+
int size = maxSize == minSize ? maxSize : minSize + ThreadLocalRandom.current().nextInt(maxSize - minSize);
161159

162160
byte[] obj = new byte[size];
163161

@@ -168,13 +166,7 @@ public void testBatchRebalance() throws Exception {
168166
streamer.addData(srcMap);
169167
}
170168

171-
srcMap.put(1, new byte[65536]);
172-
173-
node.cache(DEF_CACHE_NAME).put(1, new byte[65536]);
174-
175-
log.info("Done");
176-
177-
IgniteCache cache = node.cache(DEF_CACHE_NAME);
169+
log.info("Data loaded.");
178170

179171
if (persistence)
180172
node.cluster().active(false);
@@ -191,16 +183,12 @@ public void testBatchRebalance() throws Exception {
191183
node.cluster().setBaselineTopology(list);
192184
}
193185

194-
log.info("await rebalance");
186+
log.info("Await rebalance.");
195187

196188
awaitRebalance(node2, DEF_CACHE_NAME);
197189

198-
U.sleep(2_000);
199-
200190
node.close();
201191

202-
log.info("Verification on node2");
203-
204192
validateCacheEntries(node2.cache(DEF_CACHE_NAME), srcMap);
205193

206194
if (persistence) {
@@ -220,17 +208,17 @@ public void testBatchRebalance() throws Exception {
220208
*
221209
*/
222210
@Test
211+
@WithSystemProperty(key = IGNITE_PDS_WAL_REBALANCE_THRESHOLD, value = "100")
212+
@WithSystemProperty(key = IGNITE_DATA_STORAGE_BATCH_PAGE_WRITE, value = "true")
223213
public void testBatchHistoricalRebalance() throws Exception {
224214
if (!persistence)
225215
return;
226216

227217
// TODO https://issues.apache.org/jira/browse/IGNITE-7384
228-
// http://apache-ignite-developers.2346864.n4.nabble.com/Historical-rebalance-td38380.html
218+
// TODO http://apache-ignite-developers.2346864.n4.nabble.com/Historical-rebalance-td38380.html
229219
if (cacheAtomicityMode == CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT)
230220
return;
231221

232-
System.setProperty(IGNITE_PDS_WAL_REBALANCE_THRESHOLD, "100");
233-
234222
Ignite node = startGrids(2);
235223

236224
node.cluster().active(true);
@@ -297,6 +285,7 @@ public void testBatchHistoricalRebalance() throws Exception {
297285
/** */
298286
@Test
299287
@Ignore
288+
@WithSystemProperty(key = IGNITE_DATA_STORAGE_BATCH_PAGE_WRITE, value = "true")
300289
public void checkStreamer() throws Exception {
301290
Ignite node = startGrids(4);
302291

@@ -342,7 +331,7 @@ private void awaitRebalance(IgniteEx node, String name) throws IgniteInterrupted
342331
}
343332
}, 60_000);
344333

345-
U.sleep(1000);
334+
U.sleep(3000);
346335

347336
assertTrue(ok);
348337
}
@@ -353,20 +342,16 @@ private void awaitRebalance(IgniteEx node, String name) throws IgniteInterrupted
353342
*/
354343
@SuppressWarnings("unchecked")
355344
private void validateCacheEntries(IgniteCache cache, Map<?, byte[]> map) {
356-
log.info("Cache validation: " + map.size());
345+
int size = cache.size();
357346

358-
assertEquals(map.size(), cache.size());
359-
360-
for (Map.Entry<?, byte[]> e : map.entrySet()) {
361-
String idx = "idx=" + e.getKey();
347+
assertEquals("Cache size mismatch.", map.size(), size);
362348

363-
byte[] bytes = (byte[])cache.get(e.getKey());
349+
log.info("Validation " + cache.getName() + ", size=" + size);
364350

365-
assertNotNull(idx, bytes);
366-
367-
assertEquals(idx + ": length not equal", e.getValue().length, bytes.length);
351+
for (Map.Entry<?, byte[]> e : map.entrySet()) {
352+
String idx = "key=" + e.getKey();
368353

369-
assertArrayEquals(idx, e.getValue(), bytes);
354+
assertArrayEquals(idx, e.getValue(), (byte[])cache.get(e.getKey()));
370355
}
371356
}
372357

@@ -387,3 +372,5 @@ private <K, V> CacheConfiguration<K, V> ccfg(int parts, CacheMode mode) {
387372
.setAtomicityMode(cacheAtomicityMode);
388373
}
389374
}
375+
376+

0 commit comments

Comments
 (0)