-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-25641 Fix discrepancy with CacheStore in case of an error during tx commit phase #12178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
f3a61a5
cdd6191
88fbe08
621ddea
56de4aa
554a123
58c3893
3fa60bf
667a65b
26e5f5d
1efe895
a0211ff
bd0f4a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ | |
import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException; | ||
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException; | ||
import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException; | ||
import org.apache.ignite.internal.util.GridIntIterator; | ||
import org.apache.ignite.internal.util.GridSetWrapper; | ||
import org.apache.ignite.internal.util.future.GridFutureAdapter; | ||
import org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter; | ||
|
@@ -504,6 +505,43 @@ public void storeEnabled(boolean storeEnabled) { | |
return storeEnabled() && txState().storeWriteThrough(cctx); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
protected void clearCacheStoreBackedEntries() { | ||
if (txState().cacheIds() == null) | ||
return; | ||
|
||
GridIntIterator iter = txState().cacheIds().iterator(); | ||
while (iter.hasNext()) { | ||
int cacheId = iter.next(); | ||
|
||
if (cctx.cacheContext(cacheId) == null) | ||
return; | ||
|
||
if (!cctx.cacheContext(cacheId).config().isReadThrough()) | ||
return; | ||
} | ||
|
||
for (IgniteTxEntry e : writeMap().values()) { | ||
try { | ||
GridCacheEntryEx entry = e.cached(); | ||
|
||
if (e.op() != NOOP) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks pretty similar to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that this implementation looks similar to |
||
entry.clear(xidVer, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant braces There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
} | ||
} | ||
catch (Throwable t) { | ||
U.error(log, "Failed to clear transaction entries while reverting a commit.", t); | ||
|
||
if (t instanceof Error) | ||
throw (Error)t; | ||
|
||
break; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Uncommits transaction by invalidating all of its entries. Courtesy to minimize inconsistency. | ||
*/ | ||
|
@@ -512,8 +550,9 @@ protected void uncommit() { | |
try { | ||
GridCacheEntryEx entry = e.cached(); | ||
|
||
if (e.op() != NOOP) | ||
if (e.op() != NOOP) { | ||
entry.invalidate(xidVer); | ||
} | ||
} | ||
catch (Throwable t) { | ||
U.error(log, "Failed to invalidate transaction entries while reverting a commit.", t); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks weird. Is it really possible? Maybe get config from cache descriptor? (
cctx.cache().cacheDescriptor(cacheId).cacheConfiguration()
)If there are caches in tx, that is not isReadThrough, entries will not be cleared. Is it ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this null check as it indeed looks redundant.
About not read-through caches. It is possible of cource to clear all involved caches unconditionally but I tried to avoid touching caches that are not backed by CacheStore thus we cannot recover their values easily. That was my motivation.
But it is possible to clear only read-through caches and leave all others - do you think it is a better idea?
Clear only the data you can easily recover.