Details
-
Bug
-
Resolution: Fixed
-
Major
-
None
-
None
-
None
-
1
Description
Issue found in the following documentation https://docs.couchbase.com/server/current/learn/data/data.html#keys
The following is no longer true since 7.0 (collections)
May be no longer than 250 bytes
The limit now depends on the target collection.
- When writing to the default collection (implicitly or explicitly) 250 bytes is correct
- When writing to any other collection 246 bytes is the maximum length
The reason here comes from the way collections changed the binary protocol with its use of variable length encoding of the collection-ID being used, this is probably not required in the docs but the following is for reference.
- The default collection is represented as ID 0 and encodes into 1 byte
- Non default collections are all the other values that a 4-byte integer can encode and may require from 1 to 5 bytes when encoded with our variable encoding.
- The protocol uses a 1 byte field to state the encoded key length (allowing up to 255) but the protocol doesn't want to permit all possible 1 byte lengths, reserving some for future use - hence 251 is the maximum permitted length of key with collection prefix.
- https://github.com/couchbase/kv_engine/blob/master/docs/Collections.md#example-command