Skip to content

Panic: index out of range in sliceColumnsByIndices during high concurrency writes #130

Description

@khalid244

Panic: index out of range in sliceColumnsByIndices during high concurrency writes

Environment

  • Arc version: 26.01.2
  • Kubernetes, single arc-write pod

Reproduce

  1. Send high volume writes to /api/v1/write/line-protocol
  2. 48 concurrent workers, 5000-row batches
  3. 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().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions