MCPcopy
hub / github.com/grafana/tempo / Update

Method Update

tempodb/blocklist/list.go:104–123  ·  view source on GitHub ↗

Update Adds and removes regular or compacted blocks from the in-memory blocklist. Changes are temporary and will be preserved only for one poll

(tenantID string, add []*backend.BlockMeta, remove []*backend.BlockMeta, compactedAdd []*backend.CompactedBlockMeta, compactedRemove []*backend.CompactedBlockMeta)

Source from the content-addressed store, hash-verified

102// Update Adds and removes regular or compacted blocks from the in-memory blocklist.
103// Changes are temporary and will be preserved only for one poll
104func (l *List) Update(tenantID string, add []*backend.BlockMeta, remove []*backend.BlockMeta, compactedAdd []*backend.CompactedBlockMeta, compactedRemove []*backend.CompactedBlockMeta) {
105 if tenantID == "" {
106 return
107 }
108
109 l.mtx.Lock()
110 defer l.mtx.Unlock()
111
112 l.updateInternal(tenantID, add, remove, compactedAdd, compactedRemove)
113
114 // We have updated the current blocklist, but we may be in the middle of a
115 // polling cycle. When the Apply is called above, we will have lost the
116 // changes that we have just added. So we keep track of them here and apply
117 // them again after the Apply to save them for the next polling cycle. On
118 // the next polling cycle, the changes here will rediscovered.
119 l.added[tenantID] = append(l.added[tenantID], add...)
120 l.removed[tenantID] = append(l.removed[tenantID], remove...)
121 l.compactedAdded[tenantID] = append(l.compactedAdded[tenantID], compactedAdd...)
122 l.compactedRemoved[tenantID] = append(l.compactedRemoved[tenantID], compactedRemove...)
123}
124
125// updateInternal exists to do the work of applying updates to held PerTenant and PerTenantCompacted maps
126// it must be called under lock

Callers 7

retainTenantMethod · 0.45
markCompactedFunction · 0.45
TestUpdateFunction · 0.45
TestUpdateCompactedFunction · 0.45
TestUpdatesSavedFunction · 0.45
BenchmarkUpdateFunction · 0.45

Calls 1

updateInternalMethod · 0.95

Tested by 4

TestUpdateFunction · 0.36
TestUpdateCompactedFunction · 0.36
TestUpdatesSavedFunction · 0.36
BenchmarkUpdateFunction · 0.36