# Buggy code
def __init__(self, database: Database, db_conn, hs):
    super(MonthlyActiveUsersStore, self).__init__(database, db_conn, hs)
    self._clock = hs.get_clock()
    self.hs = hs
    # Do not add more reserved users than the total allowable number
    self.db.new_transaction(
        db_conn,
        "initialise_mau_threepids",
        [],
        [],
        self._initialise_reserved_users,
        hs.config.mau_limits_reserved_threepids[: self.hs.config.max_mau_value],
    )


# Traceback (exceptions.AttributeError)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]: 2019-02-13 17:56:49,005 - synapse.http.server - 112 - ERROR - PUT-362- Failed handle request via <function _async_render at 0x7ff0363d32a8>: <XForwardedForRequest at 0x7ff02cca4b48 method=u'PUT' uri=u'/_matrix/client/r0/rooms/<<ROOM ID>>/send/m.room.message/163970?user_id=<<USER ID>>&amp;access_token=<redacted>&amp;ts=1477692257000' clientproto=u'HTTP/1.1' site=18095>: Traceback (most recent call last):
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     current.result = callback(current.result, *args, **kw)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1475, in gotResult
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     _inlineCallbacks(r, g, status)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     result = result.throwExceptionIntoGenerator(g)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     return g.throw(self.type, self.value, self.tb)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]: --- <exception caught here> ---
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/synapse/http/server.py", line 81, in wrapped_request_handler
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     yield h(self, request)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     result = result.throwExceptionIntoGenerator(g)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     return g.throw(self.type, self.value, self.tb)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/synapse/http/server.py", line 316, in _async_render
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     callback_return = yield callback(request, **kwargs)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     result = result.throwExceptionIntoGenerator(g)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     return g.throw(self.type, self.value, self.tb)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/synapse/rest/client/v1/room.py", line 217, in on_POST
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     txn_id=txn_id,
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     result = result.throwExceptionIntoGenerator(g)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     return g.throw(self.type, self.value, self.tb)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/synapse/handlers/message.py", line 488, in create_and_send_nonmember_event
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     txn_id=txn_id
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     result = result.throwExceptionIntoGenerator(g)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     return g.throw(self.type, self.value, self.tb)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/synapse/handlers/message.py", line 279, in create_event
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     yield self.auth.check_auth_blocking(requester.user.to_string())
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     result = g.send(result)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:   File "/opt/synapse/env/local/lib/python2.7/site-packages/synapse/api/auth.py", line 812, in check_auth_blocking
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]:     timestamp = yield self.store.user_last_seen_monthly_active(user_id)
Feb 13 17:56:49 ip-10-1-2-232 matrix_synapse[3223]: exceptions.AttributeError: 'EventCreatorSlavedStore' object has no attribute 'user_last_seen_monthly_active'

# Fixed code
def __init__(self, database: Database, db_conn, hs):
    super(MonthlyActiveUsersStore, self).__init__(database, db_conn, hs)

    # Do not add more reserved users than the total allowable number
    # cur = LoggingTransaction(
    self.db.new_transaction(
        db_conn,
        "initialise_mau_threepids",
        [],
        [],
        self._initialise_reserved_users,
        hs.config.mau_limits_reserved_threepids[: self.hs.config.max_mau_value],
    )