An index set can be marked as
Since we are using MongoDB, there are no cross-document atomic operations or transactions so we have to take care of that ourselves.
Idea 1: Use a timestamp
We are currently using a boolean
As an alternative to the boolean flag we could use a timestamp field like
Idea 2: Coordinate on master
Another idea was to publish an event on the cluster event bus to set the default index set. All nodes subscribe to the event but only the master node will actually handle it. Since only one node should be master and the events are not processed in parallel, this should avoid interleaving writes to the index sets collection. It doesn't guarantee any order though.
This is more complicated than the timestamp idea beacuse it involves the cluster event bus and needs an event handler. It also makes the request to set the default index set async so we have to deal with that in the UI. It also fails when there is more than one active master node.
Please let me know if you have different, better ideas. Let's discuss!
…setting This removes the `default` field from the IndexSetConfig database object and creates a DefaultIndexSetConfig object in the cluster config instead. Using a cluster config object makes it easier to ensure that only one index set is the default. There is no migration to convert the `default` flag to a DefaultIndexSetConfig in the cluster config because this only happened to people using alphas and betas and the user is able to just set the default index set via the API or in the UI. (UI upcoming) Also implement the IndexSetsResource#setDefault() method to actually set the default in cluster config.
Since the default index must be there, we do not return an Optional but throw an IllegalStateException if the default index set cannot be found.