* don't fatal is DB is locked + Fix #60
This commit is contained in:
parent
a58df696cf
commit
f9a4ae2b3f
|
@ -10,6 +10,8 @@
|
|||
<p align="center">
|
||||
<img src="https://github.com/crowdsecurity/crowdsec/workflows/Go/badge.svg">
|
||||
<img src="https://github.com/crowdsecurity/crowdsec/workflows/build-binary-package/badge.svg">
|
||||
<img src="https://goreportcard.com/badge/github.com/crowdsecurity/crowdsec">
|
||||
<img src="https://img.shields.io/github/license/crowdsecurity/crowdsec">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
|
|
|
@ -14,7 +14,9 @@ func (c *Context) Flush() error {
|
|||
defer c.lock.Unlock()
|
||||
|
||||
ret := c.tx.Commit()
|
||||
|
||||
if ret.Error != nil {
|
||||
c.tx = c.Db.Begin()
|
||||
return fmt.Errorf("failed to commit records : %v", ret.Error)
|
||||
}
|
||||
c.tx = c.Db.Begin()
|
||||
|
@ -37,7 +39,7 @@ func (c *Context) AutoCommit() {
|
|||
if atomic.LoadInt32(&c.count) != 0 &&
|
||||
(atomic.LoadInt32(&c.count)%100 == 0 || time.Since(c.lastCommit) >= 500*time.Millisecond) {
|
||||
if err := c.Flush(); err != nil {
|
||||
log.Fatalf("failed to flush : %s", err)
|
||||
log.Errorf("failed to flush : %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue