Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Round of log-resetting changes #18

Merged
merged 19 commits into from
Aug 7, 2024
Merged

Round of log-resetting changes #18

merged 19 commits into from
Aug 7, 2024

Conversation

FiloSottile
Copy link
Owner

No description provided.

Based on a design by @jellevandenhooff at jellevandenhooff#1.

Fixes #11

Co-authored-by: Jelle van den Hooff <jelle@vandenhooff.name>
internal/ctlog/ctlog.go Show resolved Hide resolved
internal/ctlog/ctlog.go Outdated Show resolved Hide resolved
internal/ctlog/ctlog.go Show resolved Hide resolved
internal/ctlog/ctlog_test.go Outdated Show resolved Hide resolved
internal/ctlog/ctlog.go Show resolved Hide resolved
internal/ctlog/testlog_test.go Show resolved Hide resolved
internal/ctlog/ctlog.go Show resolved Hide resolved
internal/ctlog/ctlog_test.go Show resolved Hide resolved
internal/ctlog/ctlog_test.go Show resolved Hide resolved
internal/ctlog/ctlog.go Outdated Show resolved Hide resolved
@jellevandenhooff jellevandenhooff mentioned this pull request Aug 5, 2024
@@ -376,6 +387,7 @@ type UploadOptions struct {

var optsHashTile = &UploadOptions{Immutable: true}
var optsDataTile = &UploadOptions{Compress: true, Immutable: true}
var optsStaging = &UploadOptions{Compress: true, Immutable: true}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that in a very rare case it would be possible to get a staging bundle with the same hash and N but with different contents: if at height N certificates A and B get staged and the commit fails, then A gets staged and committed, and then B, the same final hash for N+2 would have two different bundles, one with A and B and one with just B.
Using a nonce for the staging bundle file name would prevent that from happening, but there is no place to store a nonce in the checkpoint.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Oh that's a good observation. One solution is to use the hash of the whole checkpoint that includes a timestamp, but I actually think we can show that this is fine regardless: we are worried about two staging bundles for N->M and N+k->M conflicting; the only case in which this can happen is if both N and N+k are successfully fully sequenced, because we never make progress without a full sequencing. The good news is that I think both the tiles in N->M and the tiles in N+k->M are valid to make a M tree whole from N+k, so it doesn't matter which one "wins".

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that it should not matter which write wins, and I wish the correctness argument was simpler but that doesn’t matter much.

Should the file type be marked immutable? If immutable means the file can safely be cached, yes, if it means the file will always be bit-for-bit identical (and could fail writes if not), no?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I tried writing a test for this in 4df346d but I actually think it's impossible: even if N -> N+2 and N -> N+1 manage to have the same timestamp (which is part of the leaf and so part of the tree hash and so part of the staging path) then N+1 -> N+2 can't have the same timestamp because time is required to move forward at each sequencing.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I had to mark staging uploads not immutable though, because there are differences in the serialized values that I have actually not yet figured out.

Using sqlite to save checkpoints failed at runtime because:

* Internal Mutex was a nil pointer
* The help messages explaining how to create the sqlite3 database had
  the wrong CREATE statement
* The implementation of the `LockBackend` interface had the `Fetch`
  function return a wrong object (a `dynamoCheckpoint` instead of a
  `sqliteCheckpoint`)

Closes #19

Signed-off-by: Flavio Castelli <fcastelli@suse.com>
FiloSottile added a commit that referenced this pull request Aug 7, 2024
@FiloSottile FiloSottile marked this pull request as ready for review August 7, 2024 15:22
@FiloSottile FiloSottile merged commit 96737ce into main Aug 7, 2024
2 checks passed
FiloSottile added a commit that referenced this pull request Aug 7, 2024
@FiloSottile FiloSottile deleted the filippo/reset branch August 7, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants