dsmiley commented on code in PR #3904:
URL: https://github.com/apache/solr/pull/3904#discussion_r2674839325
##########
solr/core/src/java/org/apache/solr/core/CorePropertiesLocator.java:
##########
@@ -65,6 +66,7 @@ public CorePropertiesLocator(Path coreDiscoveryRoot) {
@Override
public void create(CoreContainer cc, CoreDescriptor... coreDescriptors) {
for (CoreDescriptor cd : coreDescriptors) {
+ checkForExistingCore(cd);
Path propertiesFile = cd.getInstanceDir().resolve(PROPERTIES_FILENAME);
if (Files.exists(propertiesFile))
throw new SolrException(
Review Comment:
This is fine but I want to clarify/remind that my last review suggested the
move of the logic into here could be an opportunity to integrate with the
existing logic. It means triggering the logs/errors based on core.properites
instead of the parent dir (seems fine). Any way, this is fine if you wish.
##########
solr/core/src/java/org/apache/solr/core/CorePropertiesLocator.java:
##########
@@ -240,4 +242,23 @@ protected Properties buildCoreProperties(CoreDescriptor
cd) {
p.putAll(cd.getPersistableUserProperties());
return p;
}
+
+ protected void checkForExistingCore(CoreDescriptor cd) {
+ if (Files.exists(cd.getInstanceDir())) {
+ final boolean deleteUnknownCores =
+
EnvUtils.getPropertyAsBool("solr.cloud.delete.unknown.cores.enabled", false);
+ if (deleteUnknownCores) {
+ log.warn(
+ "Automatically deleting existing directory at [{}] for core [{}]
because solr.cloud.delete.unknown.cores.enabled is true",
+ cd.getInstanceDir().toAbsolutePath(),
+ cd.getName());
+ SolrCore.deleteUnloadedCore(cd, true, true);
+ } else {
+ log.warn(
+ "Directory at [{}] for core[{}] already exists preventing create
operation. Set solr.cloud.delete.unknown.cores.enabled=true to delete
directory. (SOLR-18008)",
Review Comment:
I would change "preventing" to "may prevent". As I look at the logic, it
appears an empty dir may work since the code following `checkForExistingCore`
only looks for core.properties existing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]