···140140 outboxEvt.ID = dbEvt.ID
141141 o.eventCache[dbEvt.ID] = &outboxEvt
142142143143- select {
144144- case o.pendingIDs <- dbEvt.ID:
145145- default:
146146- // Channel full, will try again next time
147147- }
148148-149143 if dbEvt.ID > o.lastLoadedID {
150144 o.lastLoadedID = dbEvt.ID
151145 }
152146 }
153147 o.cacheMu.Unlock()
148148+149149+ // do outside of cacheMu lock to avoid holding the lcok in the case of back pressure
150150+ for _, dbEvt := range events {
151151+ // back pressure if pendingIDs channel is full
152152+ o.pendingIDs <- dbEvt.ID
153153+ }
154154}
155155156156// runDelivery continuously pulls from pendingIDs and delivers events