sk0x50 commented on a change in pull request #5779: IGNITE-10508 Support the
new checkpoint feature not wait for the previous operation to complete
URL: https://github.com/apache/ignite/pull/5779#discussion_r253435389
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
##########
@@ -1464,25 +1484,56 @@ private long writeLockPage(long absPtr, FullPageId
fullId, boolean checkTag) {
return locked ? postWriteLockPage(absPtr, fullId) : 0;
}
+ private static long setCheckpointId(long tmpRelPtr, byte chpIdx) {
+ return (tmpRelPtr & ~CHECKPOINT_INDEX_MASK) & ((((int)chpIdx) << 56) |
~CHECKPOINT_INDEX_MASK);
+ }
+
/**
* @param absPtr Absolute pointer.
* @return Pointer to the page write buffer.
*/
private long postWriteLockPage(long absPtr, FullPageId fullId) {
PageHeader.writeTimestamp(absPtr, U.currentTimeMillis());
+ // Current checkpoint idx.
+ byte currChpIdx = currentCheckpointIdx(fullId);
+
// Create a buffer copy if the page is scheduled for a checkpoint.
- if (isInCheckpoint(fullId) && PageHeader.tempBufferPointer(absPtr) ==
INVALID_REL_PTR) {
- long tmpRelPtr =
checkpointPool.borrowOrAllocateFreePage(fullId.pageId());
+ if (isInCheckpoint(fullId)) {
+ long tmpBufferPointer = PageHeader.tempBufferPointer(absPtr);
+
+ long tmpRelPtr;
+
+ // If buffer was not created befor.
+ if (tmpBufferPointer == INVALID_REL_PTR) {
+ tmpRelPtr =
checkpointPool.borrowOrAllocateFreePage(fullId.pageId());
- if (tmpRelPtr == INVALID_REL_PTR) {
- rwLock.writeUnlock(absPtr + PAGE_LOCK_OFFSET,
OffheapReadWriteLock.TAG_LOCK_ALWAYS);
+ if (tmpRelPtr == INVALID_REL_PTR) {
+ rwLock.writeUnlock(absPtr + PAGE_LOCK_OFFSET,
OffheapReadWriteLock.TAG_LOCK_ALWAYS);
- throw new IgniteException(CHECKPOINT_POOL_OVERFLOW_ERROR_MSG +
": " + memMetrics.getName());
+ throw new
IgniteException(CHECKPOINT_POOL_OVERFLOW_ERROR_MSG + ": " +
memMetrics.getName());
+ }
+
+ tmpRelPtr = setCheckpointId(tmpRelPtr, currChpIdx);
+
+ // Pin the page until checkpoint is not finished.
+ PageHeader.acquirePage(absPtr);
}
+ else {
+ byte tmpBufferChpIdx = (byte)((tmpBufferPointer &
CHECKPOINT_INDEX_MASK) >> 56);
- // Pin the page until checkpoint is not finished.
- PageHeader.acquirePage(absPtr);
+ // Check buffer checkpoint id and current checkpoint id.
+ // If they not equal we can rewrite page content with new page
state.
Review comment:
`If they are not equal we can rewrite page content with the new page state.`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services