Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-30233

[Backport MB-29638] - Fix temp buffer size for array index

    XMLWordPrintable

Details

    • Untriaged
    • No

    Description

      As reported by a customer, insufficient buffer size can lead to panic while processing an array index entry.

      555 newEntriesBytes, newKeyCount, newbufLen, err = ArrayIndexItems(key, mdb.arrayExprPosition,
       556 mdb.arrayBuf2[workerId], mdb.isArrayDistinct, !allowLargeKeys)
      

      The encoded key coming from projector needs 3x size as tmp buf for ExplodeArray. Right now, its being set to same size as key (plus some padding) which may not be sufficient in all cases.

      panic: runtime error: slice bounds out of range
      goroutine 28350583 [running]:
      panic(0xd45380, 0xc4200160d0)
       /home/couchbase/.cbdepscache/exploded/x86_64/go-1.7.3/go/src/runtime/panic.go:500 +0x1a1 fp=0xc449363158 sp=0xc4493630c8
      runtime.panicslice()
       /home/couchbase/.cbdepscache/exploded/x86_64/go-1.7.3/go/src/runtime/panic.go:34 +0x6d fp=0xc449363188 sp=0xc449363158
      github.com/couchbase/indexing/secondary/collatejson.(*Codec).code2json(0xc449363570, 0xc4533fbc62, 0x85c, 0x239e, 0xc43eece7bd, 0x1, 0x3, 0xc43eece75d, 0x5f, 0x63, ...)
       /home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/indexing/secondary/collatejson/collate.go:374 +0x71b fp=0xc449363268 sp=0xc449363188
      ......
      github.com/couchbase/indexing/secondary/indexer.(*plasmaSlice).insertSecArrayIndex(0xc4277fbb00, 0xc4533e8000, 0x144be, 0x16000, 0xc427e3adc0, 0x20, 0x20, 0x4, 0x0)
       /home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/indexing/secondary/indexer/plasma_slice.go:556 +0x1806 fp=0xc449363cc0 sp=0xc449363768
      github.com/couchbase/indexing/secondary/indexer.(*plasmaSlice).insert(0xc4277fbb00, 0xc4533e8000, 0x144be, 0x16000, 0xc427e3adc0, 0x20, 0x20, 0x4, 0x6)
       /home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/indexing/secondary/indexer/plasma_slice.go:432 +0xa8 fp=0xc449363d20 sp=0xc449363cc0
      github.com/couchbase/indexing/secondary/indexer.(*plasmaSlice).handleCommandsWorker(0xc4277fbb00, 0x4)
       /home/couchbase/jenkins/workspace/couchbase-server-unix/goproj/src/github.com/couchbase/indexing/secondary/indexer/plasma_slice.go:393 +0x4f6 fp=0xc449363f40 
      

      Attachments

        Issue Links

          Activity

            People

              deepkaran.salooja Deepkaran Salooja
              prathibha Prathibha Bisarahalli (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty