Panic: index out of range in sliceColumnsByIndices during high concurrency writes
Environment
- Arc version: 26.01.2
- Kubernetes, single arc-write pod
Reproduce
- Send high volume writes to
/api/v1/write/line-protocol
- 48 concurrent workers, 5000-row batches
- Crash occurs intermittently during flush
Error
panic: runtime error: index out of range [20000] with length 20000
goroutine 82 [running]:
github.com/basekick-labs/arc/internal/ingest.sliceColumnsByIndices(...)
/build/internal/ingest/arrow_writer.go:2259
github.com/basekick-labs/arc/internal/ingest.(*ArrowBuffer).flushPartitionedData(...)
/build/internal/ingest/arrow_writer.go:1775
Root Cause
Race condition in flushBufferLocked() (arrow_writer.go:1817-1870):
// Line 1851: Lock released before merge
shard.mu.Unlock()
// Line 1854: Merge batches creates column arrays
merged, err := b.mergeBatches(recordsToFlush)
// Line 1862: Flush uses these arrays
b.flushBufferLockedDataTime(...)
In flushPartitionedData():
groupByHour(times) creates indices 0..N-1 based on times length
sliceColumnsByIndices(merged, bucket.indices) accesses other columns using these indices
- If another column has different length due to race → panic
Suggested Fix
Add bounds check in sliceColumnsByIndices():
for i, idx := range indices {
if idx >= len(col) {
return nil, fmt.Errorf("index %d out of bounds for column %s (len=%d)", idx, colName, len(col))
}
newCol[i] = col[idx]
}
Or validate all columns have equal length after mergeBatches().
Panic: index out of range in sliceColumnsByIndices during high concurrency writes
Environment
Reproduce
/api/v1/write/line-protocolError
Root Cause
Race condition in
flushBufferLocked()(arrow_writer.go:1817-1870):In
flushPartitionedData():groupByHour(times)creates indices0..N-1based ontimeslengthsliceColumnsByIndices(merged, bucket.indices)accesses other columns using these indicesSuggested Fix
Add bounds check in
sliceColumnsByIndices():Or validate all columns have equal length after
mergeBatches().