| 286 | } |
| 287 | |
| 288 | func (i *IndexLocker) RemoveOld(hours int) { |
| 289 | i.Lock() |
| 290 | defer i.Unlock() |
| 291 | currTime := time.Now() |
| 292 | expireTime := currTime.Add(time.Duration(hours*-1) * time.Hour) |
| 293 | for id, names := range i.nodes { |
| 294 | for n, info := range names { |
| 295 | if info.CreatedOn.Before(expireTime) { |
| 296 | logger.Error(fmt.Sprintf("Removing stale index lock: node=%s, index=%s", id, n)) |
| 297 | delete(names, n) |
| 298 | } |
| 299 | } |
| 300 | if len(names) == 0 { |
| 301 | delete(i.nodes, id) |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | // hacky function for debugging |
| 307 | func getGID() uint64 { |