PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: ariga/atlas (go)

Issue:
The memory usage is growing unlimitedly
# issue

The memory usage is growing unlimitedly as the revision table grows.

# usecase

Especially when using atlas for DML frequently, `atlas_schema_revisions` table grows rapidly and so does the memory usage, which is not scalable.

# code

https://github.com/ariga/atlas/blob/5bb5954fa4b91abb11dad4dd95d87164896bd59e/cmd/atlas/internal/migrate/migrate.go#L148-L151

Pull request:
sql/migrate: remove partial hashes on successful apply
Close #3311 

Patch:
diff --git a/sql/migrate/migrate.go b/sql/migrate/migrate.go
index 7385e2fa..22bdd81b 100644
--- a/sql/migrate/migrate.go
+++ b/sql/migrate/migrate.go
@@ -837,8 +837,7 @@ func (e *Executor) Execute(ctx context.Context, m File) (err error) {
 		e.log.Log(LogError{Error: err})
 		return err
 	}
-	// Make sure to store the Revision information,
-	// if the executor was not failed to store it.
+	// Make sure to store the Revision information, if it did not fail before.
 	defer func(ctx context.Context, e *Executor, r *Revision) {
 		if !errors.As(err, new(*WriteRevisionError)) {
 			if err2 := e.writeRevision(ctx, r); err2 != nil {
@@ -886,6 +885,8 @@ func (e *Executor) Execute(ctx context.Context, m File) (err error) {
 			return err
 		}
 	}
+	// In case the file was applied successfully, clean out the partial revisions.
+	r.PartialHashes = nil
 	r.done()
 	return
 }


Test patch:
diff --git a/sql/migrate/migrate_test.go b/sql/migrate/migrate_test.go
index 7a307252..45d85ad7 100644
--- a/sql/migrate/migrate_test.go
+++ b/sql/migrate/migrate_test.go
@@ -698,6 +698,7 @@ func TestExecutor(t *testing.T) {
 	*drv = mockDriver{}
 	require.NoError(t, ex.ExecuteN(context.Background(), 1))
 	require.Equal(t, []string{"ALTER TABLE t_sub ADD c4 int;"}, drv.executed)
+	require.Nil(t, revs[len(revs)-1].PartialHashes) // cleared our on successful apply
 
 	// Everything is applied.
 	require.ErrorIs(t, ex.ExecuteN(context.Background(), 0), migrate.ErrNoPendingFiles)