Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpert committed Sep 20, 2022
1 parent 75423a8 commit 995248d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions db/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ func (conn *SqliteStreamDB) consumeReplicationEvent(event *ChangeLogEvent) error
log.Debug().
Str("table", event.TableName).
Str("type", event.Type).
Int64("id", event.Id).
Msg(fmt.Sprintf("Consuming replication event with PK %v", primaryKeyMap))
Int64("event_id", event.Id).
Msg(fmt.Sprintf("Replicating %v", primaryKeyMap))
return replicateRow(tnx, event, primaryKeyMap)
})
}
Expand Down Expand Up @@ -217,7 +217,7 @@ func (conn *SqliteStreamDB) publishChangeLog() {
log.Debug().
Int64("cleaned", cnt).
Uint64("published", processed).
Msg("Rows published")
Msg("Cleaned up change log")
}
}

Expand Down
9 changes: 9 additions & 0 deletions lib/sqlite_log_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package lib

import (
"database/sql"
"errors"
"fmt"
"math"
"time"
Expand Down Expand Up @@ -50,6 +51,7 @@ const (

//go:embed log_db_script.sql
var logDBScript string
var errIndexNotApplicable = errors.New("index can not be applied for this save type")

func NewSQLiteLogDBFactory(metaPath string, nodeID uint64) *SQLiteLogDBFactory {
path := fmt.Sprintf("%s/logdb-%d.sqlite?_journal=wal", metaPath, nodeID)
Expand Down Expand Up @@ -615,6 +617,13 @@ func saveInfoTuple(
entryType raftInfoEntryType,
f func() ([]byte, error),
) error {
// Assert that BootStrap and State has no index
if entryType == Bootstrap || entryType == State {
if index != nil {
return errIndexNotApplicable
}
}

data, err := f()
if err != nil {
return err
Expand Down

0 comments on commit 995248d

Please sign in to comment.