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

WIP {!join cacheEventually=true ...}... #623

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mkhludnev
Copy link
Member

No description provided.

// make cross core joins time-agnostic
// it should be ruled by param probably
boolean crossCoreCache = false;
if(localParams.getBool("cacheEventually", false)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

introducing {!join cacheEventually=true ...}...

// it should be ruled by param probably
boolean crossCoreCache = false;
if(localParams.getBool("cacheEventually", false)) {
if (query instanceof JoinQuery) {
Copy link
Member Author

Choose a reason for hiding this comment

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

two avoid those ugly instanceofs I'd like to unify existing JoinQP routines to unify and extract common ancestor.

if(localParams.getBool("cacheEventually", false)) {
if (query instanceof JoinQuery) {
if (((JoinQuery) query).fromCoreOpenTime != 0L) {
((JoinQuery) query).fromCoreOpenTime = Long.MIN_VALUE;
Copy link
Member Author

Choose a reason for hiding this comment

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

I need these queries match to each other for cache hit regardless of commit in fromCore. It can be done by setting some additional flag and changing equals&hashCode. WDYT?

WrappedQuery wrap = new WrappedQuery(query);
wrap.setCache(false); //bypassing searcher cache
@SuppressWarnings("unchecked")
final SolrCache<Query,DocSet> rightSideCache = (SolrCache<Query,DocSet>) req.getSearcher().getCache(fromIndex);
Copy link
Member Author

Choose a reason for hiding this comment

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

It uses left side core user cache by right side (fromCore) name. I suppose it's a clear convention.

final Filter topFilter = docset.getTopFilter();

WrappedQuery wrappedCache = new WrappedQuery(topFilter);
wrappedCache.setCache(false);
Copy link
Member Author

Choose a reason for hiding this comment

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

return non-cached query backed on doc set cached in user cache

</commitWithin>
</updateHandler>

<updateProcessor name="refresh-join-caches" class="solr.RefreshCrossCoreJoinCacheFactory"/>
Copy link
Member Author

Choose a reason for hiding this comment

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

This guy from the right side (fromCore) refreshes left side (to) caches.

import java.util.List;
import java.util.Map;

public class RefreshCrossCoreJoinCacheFactory extends UpdateRequestProcessorFactory {
Copy link
Member Author

Choose a reason for hiding this comment

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

kicked on fromCore

String rightSideCore = req.getCore().getName();
for (String leftCoreName: loadedCoreNames){
if (!leftCoreName.equals(rightSideCore)) {
final SolrCore core = coreContainer.getCore(leftCoreName);
Copy link
Member Author

Choose a reason for hiding this comment

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

Enumerates all possible "to" cores, find user cache with name "fromCore".

SolrQueryResponse rsp = new SolrQueryResponse();
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(leftReq, rsp));
try {
joinCache.warm(leftSearcher.get(), joinCache);
Copy link
Member Author

Choose a reason for hiding this comment

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

Self warm left side caches picking fresh "fromCore" searcher.

} else { // commit into main index refreshes cache as well
assertU(add(doc("id", "99999999")));
assertU(commit()); // TODO this causes an error.
// cached join leaks as query result key,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a problem so far. Doc set from old searcher breaks warming of fresh searcher. Have no solution.

@Override public void close() { }
};
SolrQueryResponse rsp = new SolrQueryResponse();
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(leftReq, rsp));
Copy link

Choose a reason for hiding this comment

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

RESOURCE_LEAK: resource of type org.apache.solr.search.RefreshCrossCoreJoinCacheFactory$1$1 acquired by call to RefreshCrossCoreJoinCacheFactory$1$1(...) at line 51 is not released after line 56.
Note: potential exception at line 56

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@mkhludnev mkhludnev force-pushed the background-join-warmer branch from b291101 to 8f2f333 Compare July 11, 2022 09:38
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

Successfully merging this pull request may close these issues.

1 participant