Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Error doing update: AttributeError: 'str' object has no attribute 'get' #7784

Closed
gergof opened this issue Jul 5, 2020 · 2 comments · Fixed by #7850
Closed

Error doing update: AttributeError: 'str' object has no attribute 'get' #7784

gergof opened this issue Jul 5, 2020 · 2 comments · Fixed by #7850
Assignees
Labels
z-bug (Deprecated Label) Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution z-p2 (Deprecated Label)

Comments

@gergof
Copy link

gergof commented Jul 5, 2020

Description

When starting synapse errors like this are spammed all over the log:

2020-07-05 10:59:39,226 - synapse.storage.background_updates - 227 - INFO - background_updates-0 - Starting update batch on background update 'insert_room_retention'
2020-07-05 10:59:39,232 - synapse.storage.background_updates - 114 - ERROR - background_updates-0 - Error doing update
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/synapse/storage/background_updates.py", line 111, in run_background_updates
    self.BACKGROUND_UPDATE_DURATION_MS
  File "/usr/local/lib/python3.7/site-packages/synapse/storage/background_updates.py", line 222, in do_next_background_update
    await self._do_background_update(desired_duration_ms)
  File "/usr/local/lib/python3.7/site-packages/synapse/storage/background_updates.py", line 255, in _do_background_update
    items_updated = await update_handler(progress, batch_size)
  File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/local/lib/python3.7/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/local/lib/python3.7/site-packages/synapse/storage/data_stores/main/room.py", line 938, in _background_insert_retention
    "insert_room_retention", _background_insert_retention_txn,
  File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/local/lib/python3.7/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/local/lib/python3.7/site-packages/synapse/storage/database.py", line 527, in runInteraction
    **kwargs
  File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/local/lib/python3.7/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/local/lib/python3.7/site-packages/synapse/storage/database.py", line 575, in runWithConnection
    self._db_pool.runWithConnection(inner_func, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/twisted/python/threadpool.py", line 250, in inContext
    result = inContext.theWork()
  File "/usr/local/lib/python3.7/site-packages/twisted/python/threadpool.py", line 266, in <lambda>
    inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
  File "/usr/local/lib/python3.7/site-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python3.7/site-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
  File "/usr/local/lib/python3.7/site-packages/twisted/enterprise/adbapi.py", line 306, in _runWithConnection
    compat.reraise(excValue, excTraceback)
  File "/usr/local/lib/python3.7/site-packages/twisted/python/compat.py", line 464, in reraise
    raise exception.with_traceback(traceback)
  File "/usr/local/lib/python3.7/site-packages/twisted/enterprise/adbapi.py", line 297, in _runWithConnection
    result = func(conn, *args, **kw)
  File "/usr/local/lib/python3.7/site-packages/synapse/storage/database.py", line 572, in inner_func
    return func(conn, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/synapse/storage/database.py", line 418, in new_transaction
    r = func(cursor, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/synapse/storage/data_stores/main/room.py", line 921, in _background_insert_retention_txn
    "min_lifetime": retention_policy.get("min_lifetime"),
AttributeError: 'str' object has no attribute 'get'

I found that here json.dumps(ev["content"]) is called which will return a string and thus retention_policy.get("min_lifetime") results in an error.

Steps to reproduce

  • start synapse

Version information

  • Homeserver: systemtest.tk
  • Version: Synapse 1.15.2, python 3.7.8

  • Install method: docker

  • Platform: docker on Debian Buster
@gergof
Copy link
Author

gergof commented Jul 5, 2020

It can be fixed by replacing retention_policy = json.dumps(ev["content"]) on line 885 with retention_policy = ev["content"]

@babolivier babolivier added z-bug (Deprecated Label) Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution z-p2 (Deprecated Label) labels Jul 7, 2020
@babolivier
Copy link
Contributor

Hey and thanks for your report and investigating! Yes it looks like your diagnostic is right, I'm not entirely sure what happened there or why it went unnoticed for such a long time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
z-bug (Deprecated Label) Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution z-p2 (Deprecated Label)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants