Provide RestHighLevelClient only after schema got fully initialized

XMLWordPrintable

    • Type: Task
    • Resolution: Done
    • Priority: L3 - Default
    • 2.4.0-alpha1, 2.4.0
    • Affects Version/s: None
    • Component/s: backend
    • None

      Currently the client is available even though the schema may not be initialized yet as this is done concurrently by ElasticSearchSchemaInitializer which also depends on the RestHighLevelClient.

      We need to encapsulate the schema initialization and the provision of the RestHighLevelClient bean and only then provide the RestHighLevelClient to other consumers that can then use it unconditionally. E.g. via a SchemaInitializingEsClientFactory that creates the client, initializes the schema and then exposes the RestHighLevelClient bean.

      given:

      • the RestHighLevelClient is injected to a service/component

      when:

      • the component uses the RestHighLevelClient

      then:

      • there is a race condition between the component that uses the RestHighLevelClient trying to access the optimize schema and the ElasticSearchSchemaInitializer initializing that schema

      expected:

      • given the RestHighLevelClient is injected it should be ready to use and the schema guaranteed to be initialized

      Note:
      this makes the usage of

      @DependsOn({"elasticSearchSchemaInitializer"})
      

      in service components obsolete

            Assignee:
            Unassigned
            Reporter:
            Sebastian Bathke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: