Repository: polarsignals/frostdb
Pull request #492 (2023-08-15 16:38:50)

remove unused metadata arg from snapshotAtTX


Patch:
diff --git a/snapshot.go b/snapshot.go
index 668e2fe..cc7d0bc 100644
--- a/snapshot.go
+++ b/snapshot.go
@@ -157,7 +157,7 @@ func (db *DB) asyncSnapshot(ctx context.Context, onSuccess func()) {
 			}
 		}
 
-		if err := db.snapshotAtTX(ctx, tx, metadata, db.snapshotWriter(tx, metadata)); err != nil {
+		if err := db.snapshotAtTX(ctx, tx, db.snapshotWriter(tx, metadata)); err != nil {
 			level.Error(db.logger).Log(
 				"msg", "failed to snapshot database", "err", err,
 			)
@@ -173,7 +173,7 @@ func (db *DB) asyncSnapshot(ctx context.Context, onSuccess func()) {
 }
 
 // snapshotAtTX takes a snapshot of the state of the database at transaction tx.
-func (db *DB) snapshotAtTX(ctx context.Context, tx uint64, txnMetadata []byte, writeSnapshot func(context.Context, io.Writer) error) error {
+func (db *DB) snapshotAtTX(ctx context.Context, tx uint64, writeSnapshot func(context.Context, io.Writer) error) error {
 	var fileSize int64
 	start := time.Now()
 	if err := func() error {
@@ -707,8 +707,8 @@ func (db *DB) snapshotsDo(ctx context.Context, dir string, callback func(tx uint
 	return nil
 }
 
-func StoreSnapshot(ctx context.Context, tx uint64, txnMetadata []byte, db *DB, snapshot io.Reader) error {
-	return db.snapshotAtTX(ctx, tx, txnMetadata, func(ctx context.Context, w io.Writer) error {
+func StoreSnapshot(ctx context.Context, tx uint64, db *DB, snapshot io.Reader) error {
+	return db.snapshotAtTX(ctx, tx, func(ctx context.Context, w io.Writer) error {
 		_, err := io.Copy(w, snapshot)
 		return err
 	})
diff --git a/table.go b/table.go
index 7950bf4..03e01da 100644
--- a/table.go
+++ b/table.go
@@ -481,7 +481,7 @@ func (t *Table) writeBlock(block *TableBlock, skipPersist, snapshotDB bool) {
 			// TODO(asubiotto): Eventually we should register a cancel function
 			// that is called with a grace period on db.Close.
 			ctx := context.Background()
-			if err := t.db.snapshotAtTX(ctx, tx, metadata, t.db.snapshotWriter(tx, metadata)); err != nil {
+			if err := t.db.snapshotAtTX(ctx, tx, t.db.snapshotWriter(tx, metadata)); err != nil {
 				level.Error(t.logger).Log(
 					"msg", "failed to write snapshot on block rotation",
 					"err", err,


Test patch:
diff --git a/snapshot_test.go b/snapshot_test.go
index 5c2777d..b360cb7 100644
--- a/snapshot_test.go
+++ b/snapshot_test.go
@@ -42,7 +42,7 @@ func TestSnapshot(t *testing.T) {
 		commit()
 
 		tx := db.highWatermark.Load()
-		require.NoError(t, db.snapshotAtTX(ctx, tx.TxnID, metadata, db.snapshotWriter(tx.TxnID, metadata)))
+		require.NoError(t, db.snapshotAtTX(ctx, tx.TxnID, db.snapshotWriter(tx.TxnID, metadata)))
 
 		txBefore := db.highWatermark.Load().TxnID
 		tx, err = db.loadLatestSnapshot(ctx)
@@ -88,7 +88,7 @@ func TestSnapshot(t *testing.T) {
 
 		// Insert a sample that should not be snapshot.
 		insertSamples(ctx, t, table, 10)
-		require.NoError(t, db.snapshotAtTX(ctx, highWatermark, nil, db.snapshotWriter(highWatermark, nil)))
+		require.NoError(t, db.snapshotAtTX(ctx, highWatermark, db.snapshotWriter(highWatermark, nil)))
 
 		// Create another db and verify.
 		snapshotDB, err := c.DB(ctx, "testsnapshot")
@@ -189,7 +189,7 @@ func TestSnapshot(t *testing.T) {
 		snapshotDB, err := c.DB(ctx, "testsnapshot")
 		require.NoError(t, err)
 		tx := db.highWatermark.Load()
-		require.NoError(t, db.snapshotAtTX(ctx, tx.TxnID, nil, db.snapshotWriter(tx.TxnID, nil)))
+		require.NoError(t, db.snapshotAtTX(ctx, tx.TxnID, db.snapshotWriter(tx.TxnID, nil)))
 		snapshotTx, err := snapshotDB.loadLatestSnapshotFromDir(ctx, db.snapshotsDir())
 		require.NoError(t, err)
 		require.NoError(