Skip to content

[BUG]: Handle version file creation with empty file paths #4552

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sanketkedia
Copy link
Contributor

@sanketkedia sanketkedia commented May 15, 2025

Description of changes

  • Improvements & Bug fixes

    • It can happen that compaction flushes to sysdb with empty file paths. This happens when there are no changes to the segments after applying the logs.
    • The sysdb handles this by keeping the previous segment file paths
    • However versioning missed handling this case in the version file. This led to creation of versions with empty file paths in the version file.
    • Consequently, after GC deletes all old versions and only leaves this version with empty file paths, there is no data on S3.
  • New functionality

Test plan

  • Added a local test with mock s3

Documentation Changes

None

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sanketkedia sanketkedia changed the title [BUG]: Handle version creation with empty file paths [BUG]: Handle version file creation with empty file paths May 15, 2025
@sanketkedia sanketkedia requested review from codetheweb and HammadB May 15, 2025 06:31
@sanketkedia sanketkedia marked this pull request as ready for review May 15, 2025 06:31
Copy link
Contributor

Fix Version File Creation with Empty File Paths

This PR fixes a bug where compaction could flush to sysdb with empty file paths (which happens when there are no changes to segments after applying logs). While sysdb handled this correctly by keeping the previous segment file paths, versioning was creating versions with empty file paths in the version file. This could lead to data loss in S3 after garbage collection.

Key Changes:
• Modified updateVersionFileInS3 to reuse previous segment info when flush segment compactions are empty
• Updated model.Collection with additional fields to support this fix
• Added a test case for the empty file paths scenario

Affected Areas:
• go/pkg/sysdb/coordinator/table_catalog.go
• go/pkg/sysdb/coordinator/model/collection.go
• go/pkg/sysdb/coordinator/model_db_convert.go

This summary was automatically generated by @propel-code-bot

@@ -1544,7 +1559,8 @@ func (tc *Catalog) FlushCollectionCompactionForVersionedCollection(ctx context.C
for numAttempts < maxAttempts {
numAttempts++
// Get the current version info and the version file from the table.
collectionEntry, err := tc.metaDomain.CollectionDb(ctx).GetCollectionEntry(types.FromUniqueID(flushCollectionCompaction.ID), nil)
collectionEntry, segments, err := tc.GetCollectionWithSegments(ctx, flushCollectionCompaction.ID)
// collectionEntry, err := tc.metaDomain.CollectionDb(ctx).GetCollectionEntry(types.FromUniqueID(flushCollectionCompaction.ID), nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

?

@@ -1574,15 +1590,16 @@ func (tc *Catalog) FlushCollectionCompactionForVersionedCollection(ctx context.C
}

existingVersionFileName := collectionEntry.VersionFileName
// existingSegments := segments
Copy link
Collaborator

Choose a reason for hiding this comment

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

?

@@ -21,6 +23,10 @@ type Collection struct {
TotalRecordsPostCompaction uint64
SizeBytesPostCompaction uint64 // Note: This represents the size of the records off the log
LastCompactionTimeSecs uint64
IsDeleted bool
VersionFileName string
CreatedAt time.Time
Copy link
Contributor

Choose a reason for hiding this comment

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

is created at different than the Ts field?

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