mirror of https://github.com/status-im/consul.git
Get only first service to test whether we have to cleanup index of a service
This commit is contained in:
parent
bac8fb046f
commit
4f10fae3c3
|
@ -1052,8 +1052,8 @@ func (s *Store) deleteServiceTxn(tx *memdb.Txn, idx uint64, nodeName, serviceID
|
|||
}
|
||||
|
||||
svc := service.(*structs.ServiceNode)
|
||||
if remainingServicesItr, err := tx.Get("services", "service", svc.ServiceName); err == nil {
|
||||
if remainingServicesItr != nil && remainingServicesItr.Next() != nil {
|
||||
if remainingService, err := tx.First("services", "service", svc.ServiceName); err == nil {
|
||||
if remainingService != nil {
|
||||
// We have at least one remaining service, update the index
|
||||
if err := tx.Insert("index", &IndexEntry{serviceIndexName(svc.ServiceName), idx}); err != nil {
|
||||
return fmt.Errorf("failed updating index: %s", err)
|
||||
|
|
Loading…
Reference in New Issue