feat(backend): removed optimize call
This commit is contained in:
parent
2a926d038d
commit
7502ad76df
2 changed files with 0 additions and 22 deletions
|
|
@ -2,23 +2,18 @@ package datasaver
|
|||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"openreplay/backend/pkg/db/clickhouse"
|
||||
"openreplay/backend/pkg/db/types"
|
||||
"openreplay/backend/pkg/env"
|
||||
"openreplay/backend/pkg/messages"
|
||||
)
|
||||
|
||||
var finalizeTicker <-chan time.Time
|
||||
|
||||
func (si *Saver) InitStats() {
|
||||
si.ch = clickhouse.NewConnector(env.String("CLICKHOUSE_STRING"))
|
||||
if err := si.ch.Prepare(); err != nil {
|
||||
log.Fatalf("Clickhouse prepare error: %v\n", err)
|
||||
}
|
||||
si.pg.Conn.SetClickHouse(si.ch)
|
||||
finalizeTicker = time.Tick(20 * time.Minute)
|
||||
}
|
||||
|
||||
func (si *Saver) InsertStats(session *types.Session, msg messages.Message) error {
|
||||
|
|
@ -44,15 +39,5 @@ func (si *Saver) InsertStats(session *types.Session, msg messages.Message) error
|
|||
}
|
||||
|
||||
func (si *Saver) CommitStats(optimize bool) error {
|
||||
if !optimize {
|
||||
return si.ch.Commit()
|
||||
}
|
||||
select {
|
||||
case <-finalizeTicker:
|
||||
if err := si.ch.FinaliseSessionsTable(); err != nil {
|
||||
log.Printf("Stats: FinaliseSessionsTable returned an error. %v", err)
|
||||
}
|
||||
default:
|
||||
}
|
||||
return si.ch.Commit()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,13 +157,6 @@ func (c *connectorImpl) Commit() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *connectorImpl) FinaliseSessionsTable() error {
|
||||
if err := c.conn.Exec(context.Background(), "OPTIMIZE TABLE sessions FINAL"); err != nil {
|
||||
return fmt.Errorf("can't finalise sessions table: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *connectorImpl) checkError(name string, err error) {
|
||||
if err != clickhouse.ErrBatchAlreadySent {
|
||||
log.Printf("can't create %s batch after failed append operation: %s", name, err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue