| 88 | } |
| 89 | |
| 90 | func (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 | |
| 123 | func (o *Oracle) commit(src *api.TxnContext) error { |
| 124 | o.Lock() |