Skip to content

Commit

Permalink
IGNITE-9424 Set proper partition for key during insert - Fixes apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
akalash authored and agoncharuk committed Aug 31, 2018
1 parent 7e298d9 commit 5bb65d5
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgnitePredicate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_IDX;
Expand Down Expand Up @@ -1346,7 +1347,7 @@ private boolean canUpdateOldRow(GridCacheContext cctx, @Nullable CacheDataRow ol
@Nullable CacheDataRow oldRow) throws IgniteCheckedException {
int cacheId = grp.storeCacheIdInDataPage() ? cctx.cacheId() : CU.UNDEFINED_CACHE_ID;

DataRow dataRow = new DataRow(key, val, ver, partId, expireTime, cacheId);
DataRow dataRow = makeDataRow(key, val, ver, expireTime, cacheId);

if (canUpdateOldRow(cctx, oldRow, dataRow) && rowStore.updateRow(oldRow.link(), dataRow))
dataRow.link(oldRow.link());
Expand All @@ -1367,6 +1368,22 @@ private boolean canUpdateOldRow(GridCacheContext cctx, @Nullable CacheDataRow ol
return dataRow;
}

/**
* @param key Cache key.
* @param val Cache value.
* @param ver Version.
* @param expireTime Expired time.
* @param cacheId Cache id.
* @return Made data row.
*/
@NotNull private DataRow makeDataRow(KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime,
int cacheId) {
if (key.partition() == -1)
key.partition(partId);

return new DataRow(key, val, ver, partId, expireTime, cacheId);
}

/** {@inheritDoc} */
@Override public void update(
GridCacheContext cctx,
Expand All @@ -1386,10 +1403,7 @@ private boolean canUpdateOldRow(GridCacheContext cctx, @Nullable CacheDataRow ol

assert oldRow == null || oldRow.cacheId() == cacheId : oldRow;

if (key.partition() == -1)
key.partition(partId);

DataRow dataRow = new DataRow(key, val, ver, partId, expireTime, cacheId);
DataRow dataRow = makeDataRow(key, val, ver, expireTime, cacheId);

CacheObjectContext coCtx = cctx.cacheObjectContext();

Expand Down

0 comments on commit 5bb65d5

Please sign in to comment.