Hi Solr experts:

Question: how can I prevent multiple concurrent requests adding the same 
duplicated copyfield into managed schema? (Note: I am using Solr 6.6.2)


User case: For a new field named srcField, I need to create another field named 
destField, and a new copyField with srcField as source and destField as 
destination; and add srcField, descField, and the copyField into schema using 
following APIs:


  *   For add fields: IndexSchema.addFields(Collection<SchemaField>)
  *   For add copyField: Index.addCopyFields(Map<String, Collection<String>, 
boolean)


Adding the same field multiple time is not the issue since "field" is 
maintained as a map with field name as the key; HOWEVER, adding the same 
copyfield multiple time results duplicated copyfield entries because the value 
of the "copyFieldsMap" is a list (with source field name as the key)


For a single core, I think I can synchronizing the core schema update lock and 
check the latest core schema again before invoking above APIs to prevent this 
case. Is there better way to solve this issue?


HOWEVER, how can I prevent this issue with multiple cores sharing the same 
schema (i.e. those cores have the same instance directory containing 
managed-schema.xml) because each core has its own schema update lock. Above 
approach does not work for this case.


Please advise! Thank you so much!


--Michael

Reply via email to