Skip to content

Commit 07adae0

Browse files
Sicheng-PanSicheng Pan
and
Sicheng Pan
authored
[BUG] Fix log fork bugs (#4356)
## Description of changes *Summarize the changes made by this PR.* - Improvements & Bug fixes - Fixes a typo in log fork impl that led to wrong enumeration offset for the new collection - Replaces updates with insert when populating the offsets for the new collection - New functionality - ... ## Test plan *How are these changes tested?* - [ ] Tests pass locally with `pytest` for python, `yarn test` for js, `cargo test` for rust ## Documentation Changes *Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the [docs repository](https://github.com/chroma-core/docs)?* --------- Co-authored-by: Sicheng Pan <[email protected]>
1 parent 50b9363 commit 07adae0

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

go/pkg/common/errors.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var (
2121
ErrCollectionNameEmpty = errors.New("collection name is empty")
2222
ErrCollectionUniqueConstraintViolation = errors.New("collection unique constraint violation")
2323
ErrCollectionDeleteNonExistingCollection = errors.New("delete non existing collection")
24-
ErrCollectionLogPositionStale = errors.New("collection log position Stale")
24+
ErrCollectionLogPositionStale = errors.New("collection log position stale")
2525
ErrCollectionVersionStale = errors.New("collection version stale")
2626
ErrCollectionVersionInvalid = errors.New("collection version invalid")
2727
ErrCollectionVersionFileNameStale = errors.New("collection version file name stale")

go/pkg/log/repository/log.go

+5-12
Original file line numberDiff line numberDiff line change
@@ -168,28 +168,21 @@ func (r *LogRepository) ForkRecords(ctx context.Context, sourceCollectionID stri
168168
// Some logs are forked, the min offset is guaranteed to be larger than source compaction offset
169169
compactionOffset = uint64(targetBounds.MinOffset - 1)
170170
}
171-
err = queriesWithTx.UpdateCollectionCompactionOffsetPosition(ctx, log.UpdateCollectionCompactionOffsetPositionParams{
172-
ID: targetCollectionID,
173-
RecordCompactionOffsetPosition: int64(compactionOffset),
174-
})
175-
if err != nil {
176-
trace_log.Error("Error in updating compaction offset for target collection", zap.Error(err), zap.String("collectionId", targetCollectionID))
177-
return
178-
}
179-
180171
if targetBounds.MaxOffset == 0 {
181172
// Either the source collection is empty or no log is forked
182173
enumerationOffset = uint64(sourceBounds.RecordEnumerationOffsetPosition)
183174
} else {
184175
// Some logs are forked. The max offset is the enumeration offset
185-
compactionOffset = uint64(targetBounds.MaxOffset)
176+
enumerationOffset = uint64(targetBounds.MaxOffset)
186177
}
187-
err = queriesWithTx.UpdateCollectionEnumerationOffsetPosition(ctx, log.UpdateCollectionEnumerationOffsetPositionParams{
178+
179+
_, err = queriesWithTx.InsertCollection(ctx, log.InsertCollectionParams{
188180
ID: targetCollectionID,
181+
RecordCompactionOffsetPosition: int64(compactionOffset),
189182
RecordEnumerationOffsetPosition: int64(enumerationOffset),
190183
})
191184
if err != nil {
192-
trace_log.Error("Error in updating enumeration offset for target collection", zap.Error(err), zap.String("collectionId", targetCollectionID))
185+
trace_log.Error("Error in updating offset for target collection", zap.Error(err), zap.String("collectionId", targetCollectionID))
193186
return
194187
}
195188
return

0 commit comments

Comments
 (0)