Julian Chandra Sutadi created SOLR-18632:
--------------------------------------------

             Summary: Recreated configset with the same name is still served 
from the stale config cache
                 Key: SOLR-18632
                 URL: https://issues.apache.org/jira/browse/SOLR-18632
             Project: Solr
          Issue Type: Bug
            Reporter: Julian Chandra Sutadi


SOLR-16143 fixed a problem where a collection created from a configset that was 
deleted and re-uploaded under the same name would still get the old config. 
This is because a recreated znode starts again at version 0, so a version check 
alone treats it as unchanged. The fix added the znode's ctime to 
{{{}SolrConfig.ResourceProvider.hash{}}}, which was then used to validate the 
cached {{{}solrconfig.xml{}}}.

However, since SOLR-16336, both {{SolrConfig}} and the schema are loaded 
through {{{}IndexSchemaFactory.getFromCache{}}}, which validates cached entries 
by znode version only. The {{ResourceProvider.hash}} which takes into account 
the znode's ctime is still computed but no longer read

{code:java}
// SolrConfig.ResourceProvider: the SOLR-16143 fix
zkVersion = zkin.getStat().getVersion();
hash = Objects.hash(zkin.getStat().getCtime(), zkVersion, overlay.getVersion());

// SolrConfig.readXml: only the version goes into the cache
return new IndexSchemaFactory.VersionedConfig(
    rp.zkVersion,           // was rp.hash before SOLR-16336
    new DataConfigNode(new 
DOMConfigNode(xml.getDocument().getDocumentElement())));
{code}

and the cache check compares versions only:

{code:java}
// ZkSolrResourceLoader.getZkResourceInfo
Stat stat = zkController.getZkClient().exists(file, null);
if (stat != null) {
  return new Pair<>(file, stat.getVersion());   // ctime is dropped here
}

// IndexSchemaFactory.getFromCache
Pair<String, Integer> res = zkLoader.getZkResourceInfo(name);
if (res == null) return cfgLoader.get();
VersionedConfig result = null;
result = confCache.computeIfAbsent(res.first(), k -> cfgLoader.get());
if (result.version == res.second()) {   // a recreated znode is at version 0 
again, so this matches
  return result;                        // and the old solrconfig.xml / schema 
is returned
} else {
  ...
}
{code}

To reproduce:

{code}
bin/solr start
cp -r server/solr/configsets/_default myconf
bin/solr create -c books -d myconf
bin/solr delete -c books --delete-config

sed -i.bak 's#</schema>#<field name="isbn" type="string" indexed="true" 
stored="true"/></schema>#' myconf/conf/managed-schema.xml
sed -i.bak 's#</config>#<requestHandler name="/hello" 
class="solr.SearchHandler"/></config>#' myconf/conf/solrconfig.xml
bin/solr create -c books -d myconf

curl http://localhost:8983/solr/books/schema/fields/isbn   # 404, the new field 
is missing
curl http://localhost:8983/solr/books/hello                # 404, the new 
handler is missing
{code}

We'll attach a PR soon.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to