Web / Apache Solr Interview questions
Why is leader election necessary in SolrCloud shards?
Each shard in SolrCloud can have multiple replicas, but writes need a single point of coordination to stay consistent. That's the role of the shard leader.
When a client sends an update, it can hit any replica, but that replica forwards the write to the current leader for that shard. The leader assigns a version number to the update, applies it locally, and then forwards it to all other replicas. This ordering guarantees that every replica applies updates in the same sequence, which prevents replicas from drifting out of sync when concurrent writes arrive.
If the leader crashes, ZooKeeper detects the lost ephemeral node and triggers a new election among the remaining in-sync replicas, so writes can resume without operator intervention, typically within seconds.
More Related questions...