Skip to content

Commit 296be50

Browse files
Gal TopperGal Topper
authored and
Dina Nimrodi
committed
IG-16343: Fix data loss when writing a combination of old and new data. (#516)
Co-authored-by: Gal Topper <[email protected]>
1 parent 9dec9d3 commit 296be50

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

pkg/appender/store.go

+5-16
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ type attrAppender struct {
9191
type chunkState uint8
9292

9393
const (
94-
chunkStateFirst chunkState = 1
95-
chunkStateMerge chunkState = 2
96-
chunkStateCommitted chunkState = 4
97-
chunkStateWriting chunkState = 8
94+
// chunkStateMerge chunkState = 2 - Deprecated
95+
// chunkStateCommitted chunkState = 4 - Deprecated
96+
chunkStateFirst chunkState = 1
97+
chunkStateWriting chunkState = 8
9898
)
9999

100100
// Initialize/clear the chunk appender
@@ -215,11 +215,6 @@ func (cs *chunkStore) processGetResp(mc *MetricsCache, metric *MetricState, resp
215215
cs.maxTime = maxTime
216216
}
217217

218-
if !cs.isAggr() {
219-
if cs.chunks[0].inRange(maxTime) && !mc.cfg.OverrideOld {
220-
cs.chunks[0].state |= chunkStateMerge
221-
}
222-
}
223218
// Set Last TableId - indicate that there is no need to create metric object
224219
cs.lastTid = cs.nextTid
225220
}
@@ -452,7 +447,6 @@ func (cs *chunkStore) ProcessWriteResp() {
452447
for _, chunk := range cs.chunks {
453448
// Update the chunk state (if it was written to)
454449
if chunk.state&chunkStateWriting != 0 {
455-
chunk.state |= chunkStateCommitted
456450
chunk.state &^= chunkStateWriting
457451
chunk.appender.Chunk().Clear()
458452
}
@@ -475,12 +469,7 @@ func (cs *chunkStore) appendExpression(chunk *attrAppender) string {
475469

476470
val := base64.StdEncoding.EncodeToString(bytes)
477471

478-
// Overwrite, merge, or append based on the chunk state
479-
if chunk.state&chunkStateCommitted != 0 || chunk.state&chunkStateMerge != 0 {
480-
expr = fmt.Sprintf("%s=if_not_exists(%s,blob('')) + blob('%s'); ", attr, attr, val)
481-
} else {
482-
expr = fmt.Sprintf("%s=blob('%s'); ", attr, val)
483-
}
472+
expr = fmt.Sprintf("%s=if_not_exists(%s,blob('')) + blob('%s'); ", attr, attr, val)
484473

485474
return expr
486475

0 commit comments

Comments
 (0)