Skip to content
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

Query/Issue on Transactions and DirtyReads #11836

Open
vitthalbywar-tibco opened this issue Jan 29, 2025 · 2 comments
Open

Query/Issue on Transactions and DirtyReads #11836

vitthalbywar-tibco opened this issue Jan 29, 2025 · 2 comments

Comments

@vitthalbywar-tibco
Copy link

Hello,

We have a scenario where we are deleting entries from a "transactional" cache in one thread in a transaction and in parallel another thread is trying to query on the same cache. We observe changing/random numbers in second call when queried on the cache. Is this not a correct expectation that until the first transaction complete(delete), second query should return either count before delete transaction or count after delete transaction?

Example -
1: Cache has 1000 entries
2: A new thread tries to delete all entries using removeAll(keys) method.
3: Another thread in parallel when they to do cache.size() it gets range of numbers between 1000-0. Should it not be always 1000 or 0 considering point 2 is happening in a transaction?

Please refer attached sample project.

transactions-test.zip

Please suggest.

Thank you,

@vitthalbywar-tibco
Copy link
Author

Version used 2.16

@sk0x50
Copy link
Contributor

sk0x50 commented Feb 5, 2025

Hello @vitthalbywar-tibco ,

Is this not a correct expectation that until the first transaction complete(delete), second query should return either count before delete transaction or count after delete transaction?

Well, your expectation is "incorrect". The IgniteCache.size() does not participate in any transactions, in other words, this method is not transactional. Moreover, it is implemented using an internal compute task, where each job calculates the cache size on a node independently.

    /**
     * Gets the number of all entries cached across all nodes. 
     ...
     * NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
     ...
     */
    public int size(CachePeekMode... peekModes) throws CacheException;

Thanks,
S.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants