MCPcopy
hub / github.com/dgraph-io/dgraph / purgeBelow

Method purgeBelow

dgraph/cmd/zero/oracle.go:90–121  ·  view source on GitHub ↗
(minTs uint64)

Source from the content-addressed store, hash-verified

88}
89
90func (o *Oracle) purgeBelow(minTs uint64) {
91 var timer x.Timer
92 timer.Start()
93
94 o.Lock()
95 defer o.Unlock()
96
97 // Set startTxnTs so that every txn with start ts less than this, would be aborted.
98 o.startTxnTs = minTs
99
100 // Dropping would be cheaper if abort/commits map is sharded
101 for ts := range o.commits {
102 if ts < minTs {
103 delete(o.commits, ts)
104 }
105 }
106 timer.Record("commits")
107
108 // There is no transaction running with startTs less than minTs
109 // So we can delete everything from rowCommit whose commitTs < minTs
110 stats := o.keyCommit.Stats()
111 if stats.Occupancy < 50.0 {
112 return
113 }
114 o.keyCommit.DeleteBelow(minTs)
115 timer.Record("deleteBelow")
116 glog.V(2).Infof("Purged below ts:%d, len(o.commits):%d, keyCommit: [before: %+v, after: %+v].\n",
117 minTs, len(o.commits), stats, o.keyCommit.Stats())
118 if timer.Total() > time.Second {
119 glog.V(2).Infof("Purge %s\n", timer.String())
120 }
121}
122
123func (o *Oracle) commit(src *api.TxnContext) error {
124 o.Lock()

Callers 1

applySnapshotMethod · 0.80

Calls 7

StartMethod · 0.95
RecordMethod · 0.95
TotalMethod · 0.95
StringMethod · 0.95
InfofMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected