Uploaded image for project: 'Couchbase Go SDK'
  1. Couchbase Go SDK
  2. GOCBC-1320

Intermittent KEY_ENOENT loading travel_sample airport document due to incorrect hash function in gocbcore

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.5.2, core-10.1.4
    • core-10.0.8
    • core-library
    • None
    • 1

    Description

      Getting failure on GET of travel_sample document, whose ID was just read in previous query.

      1. Install travel_sample
      2. Wait for def_inventory_airport_primary index to come online
      3. Collect all airport IDs with: select value(meta().id) from `travel-sample`.inventory.airport query
      4. For each airport ID collected above, get the document by ID, which intermittently fails with a KEY_ENOENT failure.

      e.g.

      com.couchbase.client.core.error.DocumentNotFoundException: Document with the given id not found {"completed":true,"coreId":"0xaff20d7300000001","idempotent":true,"lastChannelId":"AFF20D7300000001/000000002B106D1C","lastDispatchedFrom":"172.18.0.3:48012","lastDispatchedTo":"172.18.0.3:12004","requestId":158,"requestType":"GetRequest","retried":0,"service":{"bucket":"travel-sample","collection":"airport","documentId":"airport_8607","errorCode":{"description":"Not Found","name":"KEY_ENOENT"},"opaque":"0x97","scope":"inventory","type":"kv","vbucket":42},"status":"NOT_FOUND","timeoutMs":10000,"timings":{"dispatchMicros":655498,"totalDispatchMicros":655498,"totalServerMicros":650,"totalMicros":679427,"serverMicros":650}}
      

      In the comments below we have found that this is due to the hash function. libcouchbase has:

      static uint32_t hash_crc32(const char *key, size_t key_length)
      {
          uint64_t x;
          uint32_t crc = UINT32_MAX;
       
       
          for (x = 0; x < key_length; x++)
              crc = (crc >> 8) ^ crc32tab[(crc ^ (uint64_t)key[x]) & 0xff];
       
       
          return ((~crc) >> 16) & 0x7fff;
      } 
      

      but we have:

      func cbCrc(key []byte) uint32 {
      	crc := uint32(0xffffffff)
      	for x := 0; x < len(key); x++ {
      		crc = (crc >> 8) ^ crc32tab[(uint64(crc)^uint64(key[x]))&0xff]
      	}
      	return (^crc) >> 16
      }
      

      Attachments

        Activity

          People

            charles.dixon Charles Dixon
            michael.blow Michael Blow
            Votes:
            0 Vote for this issue
            Watchers:
            14 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty