Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-5375

Error trying to decode sizeStorer table: can't concat str to bytes

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Language Bindings
    • None
    • 1
    • Storage Engines 2020-01-13

      Using the wiredtiger Python library to decode a MongoDB sizeStorer table results in an encoding error in Python 3.7:

      Traceback (most recent call last):
      File "sizeStorer.py", line 31, in <module>
      size = sizeStorer[ident]
      File ".../python3.7/site-packages/wiredtiger/wiredtiger.py", line 441, in _getitem_
      self.set_key(key)
      File ".../python3.7/site-packages/wiredtiger/wiredtiger.py", line 410, in set_key
      self._key = pack(self.key_format, *args)
      File ".../python3.7/site-packages/wiredtiger/packing.py", line 183, in pack
      result += val[:l]
      TypeError: can't concat str to bytes

      The logic in wiredtiger's packing.py tries to add a string value to a result string which is bytes:

                  if _is_string(val) and f in 'Ss':
                      result += str(val[:l]).encode()
                  else:
                      result += val[:l]
      

      The sizeStorer values are apparently strings with "u" format, so match the else condition rather than the if (which would not result in an error).

      Attached is a script to repro the issue. The error was consistent with new dbpaths created in MongoDB 3.6 and 4.2 using --directoryperdb.

            Assignee:
            donald.anderson@mongodb.com Donald Anderson
            Reporter:
            stephen.steneker@mongodb.com Stennie Steneker (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: