Re-add comments

This commit is contained in:
binwiederhier
2026-02-20 16:15:07 -05:00
parent eb6e1ac44a
commit 13a3062a7f
2 changed files with 9 additions and 1 deletions

View File

@@ -98,6 +98,7 @@ func newCommonStore(db *sql.DB, queries storeQueries, batchSize int, batchTimeou
}
// AddMessage stores a message to the message cache synchronously, or queues it to be stored at a later date asynchronously.
// The message is queued only if "batchSize" or "batchTimeout" are passed to the constructor.
func (c *commonStore) AddMessage(m *model.Message) error {
if c.queue != nil {
c.queue.Enqueue(m)
@@ -376,6 +377,7 @@ func (c *commonStore) DeleteScheduledBySequenceID(topic, sequenceID string) ([]s
return nil, err
}
defer tx.Rollback()
// First, get the message IDs of scheduled messages to be deleted
rows, err := tx.Query(c.queries.selectScheduledMessageIDsBySeqID, topic, sequenceID)
if err != nil {
return nil, err
@@ -392,7 +394,8 @@ func (c *commonStore) DeleteScheduledBySequenceID(topic, sequenceID string) ([]s
if err := rows.Err(); err != nil {
return nil, err
}
rows.Close()
rows.Close() // Close rows before executing delete in same transaction
// Then delete the messages
if _, err := tx.Exec(c.queries.deleteScheduledBySequenceID, topic, sequenceID); err != nil {
return nil, err
}

View File

@@ -135,6 +135,11 @@ func NewNopStore() (Store, error) {
}
// createMemoryFilename creates a unique memory filename to use for the SQLite backend.
// From mattn/go-sqlite3: "Each connection to ":memory:" opens a brand new in-memory
// sql database, so if the stdlib's sql engine happens to open another connection and
// you've only specified ":memory:", that connection will see a brand new database.
// A workaround is to use "file::memory:?cache=shared" (or "file:foobar?mode=memory&cache=shared").
// Every connection to this string will point to the same in-memory database."
func createMemoryFilename() string {
return fmt.Sprintf("file:%s?mode=memory&cache=shared", util.RandomString(10))
}