Class: Cells::Leases::ReconciliationService

Inherits:
Object
  • Object
show all
Defined in:
app/services/cells/leases/reconciliation_service.rb

Constant Summary collapse

LEASE_STALENESS_THRESHOLD =

A lease is considered stale if not updated in the last 5 minutes

5.minutes
LIMIT =

Number of leases to process per batch when paginating through remote leases

100
ORPHANED_LEASE_CLEANUP_THRESHOLD =

Local leases older than 1 hour are forcibly deleted as orphaned

1.hour
TIMEOUT_IN_SECONDS =
1

Instance Method Summary collapse

Constructor Details

#initializeReconciliationService

Returns a new instance of ReconciliationService.



23
24
25
26
27
28
29
30
31
# File 'app/services/cells/leases/reconciliation_service.rb', line 23

def initialize
  @claim_service = Gitlab::TopologyServiceClient::ClaimService.instance
  @processed_count = 0
  @committed_count = 0
  @rolled_back_count = 0
  @pending_count = 0
  @orphaned_count = 0
  @ts_lease_uuids = Set.new
end

Instance Method Details

#executeObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/services/cells/leases/reconciliation_service.rb', line 33

def execute
  reconcile_leases
  cleanup_orphaned_leases

  {
    processed: @processed_count,
    committed: @committed_count,
    rolled_back: @rolled_back_count,
    pending: @pending_count,
    orphaned: @orphaned_count
  }
end