Skip to content

Versioning store changes#213

Open
chris124567 wants to merge 5 commits into
masterfrom
christopher/versioning-3-sqlite
Open

Versioning store changes#213
chris124567 wants to merge 5 commits into
masterfrom
christopher/versioning-3-sqlite

Conversation

@chris124567

@chris124567 chris124567 commented Jun 22, 2026

Copy link
Copy Markdown
Member

Re: #201

Due to some interdependent things, it's difficult to get everything to build. But if you run the sqlite tests specifically:

go test ./sia/persist/sqlite/ -v -count=1 

They all pass.

Before:

goos: linux
goarch: amd64
pkg: github.com/SiaFoundation/s3d/sia/persist/sqlite
cpu: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
BenchmarkListObjects/no_delimiter_no_prefix-4         	     322	   3827107 ns/op	  377759 B/op	    8572 allocs/op
BenchmarkListObjects/slash/root_delimiter-4           	      20	  55469415 ns/op	 2221026 B/op	   53194 allocs/op
BenchmarkListObjects/slash/random_without_delimiter-4 	     656	   1709676 ns/op	  155647 B/op	    3462 allocs/op
BenchmarkListObjects/slash/random_with_delimiter-4    	    1510	    833290 ns/op	   33968 B/op	     724 allocs/op
BenchmarkListObjects/slash/folder_bottom_delimiter-4  	    6331	    188681 ns/op	    9998 B/op	     181 allocs/op
BenchmarkListObjects/slash/folder_delimiter-4         	    1552	    783232 ns/op	   33772 B/op	     724 allocs/op
BenchmarkListObjects/backslash/root_delimiter-4       	      19	  56824941 ns/op	 2220394 B/op	   53202 allocs/op
BenchmarkListObjects/backslash/random_without_delimiter-4         	     596	   1775787 ns/op	  155202 B/op	    3451 allocs/op
BenchmarkListObjects/backslash/random_with_delimiter-4            	    1214	    865385 ns/op	   33974 B/op	     724 allocs/op
BenchmarkListObjects/backslash/folder_bottom_delimiter-4          	    7107	    188810 ns/op	    9995 B/op	     181 allocs/op
BenchmarkListObjects/backslash/folder_delimiter-4                 	    1593	    769560 ns/op	   33770 B/op	     724 allocs/op
PASS
ok  	github.com/SiaFoundation/s3d/sia/persist/sqlite	87.042s

After:

goos: linux
goarch: amd64
pkg: github.com/SiaFoundation/s3d/sia/persist/sqlite
cpu: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
BenchmarkListObjects/no_delimiter_no_prefix-4         	     296	   4011547 ns/op	  395252 B/op	    8550 allocs/op
BenchmarkListObjects/slash/root_delimiter-4           	      15	  72266987 ns/op	 2369141 B/op	   51211 allocs/op
BenchmarkListObjects/slash/random_without_delimiter-4 	     782	   1652186 ns/op	  142418 B/op	    3013 allocs/op
BenchmarkListObjects/slash/random_with_delimiter-4    	    1106	   1092842 ns/op	   36048 B/op	     702 allocs/op
BenchmarkListObjects/slash/folder_bottom_delimiter-4  	    5630	    231283 ns/op	   10322 B/op	     177 allocs/op
BenchmarkListObjects/slash/folder_delimiter-4         	    1182	   1037541 ns/op	   35840 B/op	     701 allocs/op
BenchmarkListObjects/backslash/root_delimiter-4       	      15	  70600722 ns/op	 2365412 B/op	   51205 allocs/op
BenchmarkListObjects/backslash/random_without_delimiter-4         	     608	   1803499 ns/op	  148958 B/op	    3154 allocs/op
BenchmarkListObjects/backslash/random_with_delimiter-4            	    1118	   1096305 ns/op	   36049 B/op	     702 allocs/op
BenchmarkListObjects/backslash/folder_bottom_delimiter-4          	    5480	    235659 ns/op	   10317 B/op	     177 allocs/op
BenchmarkListObjects/backslash/folder_delimiter-4                 	    1158	   1055111 ns/op	   35848 B/op	     701 allocs/op
PASS
ok  	github.com/SiaFoundation/s3d/sia/persist/sqlite	114.867s

Copilot AI review requested due to automatic review settings June 22, 2026 19:24
@github-project-automation github-project-automation Bot moved this to In Progress in Sia Jun 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements SQLite-backed object versioning primitives in support of Issue #201 by extending the schema and updating core object/multipart/lifecycle operations to read/write versioned rows (including delete markers) and expose version-aware listing and retrieval.

Changes:

  • Add versioning state machine in the SQLite store (per-bucket versioning status, per-object versions with version_id, seq, is_latest, and delete markers).
  • Update object and multipart code paths to be version-aware (Put/Get/Delete/Copy, object parts keyed by version, and version listing).
  • Add/extend schema initialization + migration to support versioning and add targeted tests for versioning and precondition behavior.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sia/persist/sqlite/versioning.go Adds versioning helpers and write/delete state machine (new versions, delete markers, null version handling).
sia/persist/sqlite/store.go Adjusts store wiring/comments around interface assertion while splitting versioning work.
sia/persist/sqlite/precondition_test.go Adds regression test ensuring suspended-bucket delete checks preconditions against the current version.
sia/persist/sqlite/objects.go Introduces version-aware object APIs (Put/Get/Delete/Copy), parts keyed by version, and adds ListObjectVersions implementation.
sia/persist/sqlite/objects_test.go Updates existing tests and adds new test coverage for versioning lifecycle + version listing semantics.
sia/persist/sqlite/multipart.go Makes CompleteMultipartUpload version-aware and writes parts under the created version.
sia/persist/sqlite/migrations.go Adds migration to rebuild objects/object_parts for versioning columns and adds bucket versioning status.
sia/persist/sqlite/lifecycle.go Updates object expiration to delete current versions using the versioning-aware delete logic.
sia/persist/sqlite/init.sql Updates initial schema for versioned objects/object_parts and bucket versioning status.
sia/persist/sqlite/buckets.go Adds Get/Put bucket versioning status and internal lookup helper.
sia/objects/objects.go Extends stored object model with VersionID, Versioned flag, delete-marker flag, and ObjectForUpload.VersionID.
sia/objects.go Adjusts bulk delete result construction in preparation for VersionID changing to *string.
s3/versioning.go Adds shared versioning types (VersionRequest, ListObjectVersions pagination/result types, version formatting).
s3/objects.go Updates multi-delete parsing to treat VersionId as optional and map wire "null" to internal empty string.
s3/messages.go Changes ObjectID.VersionID in delete XML messages from string to *string (nil = unspecified).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sia/persist/sqlite/lifecycle.go
Comment thread sia/persist/sqlite/objects.go Outdated
Comment thread sia/persist/sqlite/store.go

@peterjan peterjan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tough PR to go through but I think it's fine. I would repeat the benchmark results you did in the previous PR here in the PR description for documenting purposes. Especially since you were able to make it so there's minimal regression.

Comment thread sia/persist/sqlite/buckets_test.go
Comment thread sia/persist/sqlite/buckets.go Outdated
Comment thread sia/persist/sqlite/versioning.go Outdated
Comment thread sia/persist/sqlite/lifecycle.go Outdated
Comment thread sia/persist/sqlite/objects.go Outdated
@chris124567 chris124567 force-pushed the christopher/versioning-3-sqlite branch from 50f57bc to 46ca062 Compare June 23, 2026 17:36
@peterjan

Copy link
Copy Markdown
Member

hard to approve considering the build is failing but the PR looks good to me 👍

@chris124567

Copy link
Copy Markdown
Member Author

Thank you
I'm going to request reviewers on #214 then

@ChrisSchinnerl ChrisSchinnerl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't been able to go through all of it in detail but it looks promising so far.

Comment thread sia/persist/sqlite/objects.go
Comment thread sia/persist/sqlite/objects_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants