Skip to content

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

Merged
merged 13 commits into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
IGNITE-25641 Cleanup code
  • Loading branch information
sergey-chugunov-1985 committed Jul 16, 2025
commit f3a61a5b671b691652fa05028bc658546b28dc53
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ else if (op == READ) {
err = heuristicException(ex);

try {
clearCacheStoreBackedEntries();

uncommit();
}
catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

return;

if (!cctx.cacheContext(cacheId).config().isReadThrough())
return;
}

for (IgniteTxEntry e : writeMap().values()) {
try {
GridCacheEntryEx entry = e.cached();

if (e.op() != NOOP) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty similar to uncommit() method. Maybe move this code to uncommit?
Like additional condition:

if (entry.context().readThrough())
    entry.clear(xidVer, true);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this implementation looks similar to uncommit but the reason I decided to implement it in a separate method was that I wanted to keep uncommit logic untouched so no possible exceptions thrown inside clearCacheStoreBackedEntries affect uncommit. Does it make sense to you?

entry.clear(xidVer, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant braces

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
*/
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,8 @@ assert ownsLock(txEntry.cached()) :
state(UNKNOWN);

try {
clearCacheStoreBackedEntries();

uncommit();
}
catch (Throwable e) {
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy