This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix tests on postgresql #3740
Merged
Merged
Fix tests on postgresql #3740
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
259c30d
fix mau and storage
hawkowl c993c7b
fix this
hawkowl 8ec2727
fix
hawkowl 69bae95
Merge branch 'develop' of ssh://github.com/matrix-org/synapse into ha…
hawkowl 3244ee6
some fixes
hawkowl b2833b3
cleanup
hawkowl 0b9b310
require postgres
hawkowl d4be9d3
cleanups
hawkowl 02dc7ee
isort
hawkowl 4addb15
fix
hawkowl fe146fd
fix?
hawkowl 3787423
fixes
hawkowl 3e5caf6
nah
hawkowl a901cce
fix
hawkowl 17201a4
fix
hawkowl 136adaa
changelog
hawkowl 4047027
fix up some small things
hawkowl f4d1eda
make the pool running
hawkowl b017b69
fixes here too
hawkowl e752d4a
cleanups
hawkowl 729f59e
pep8
hawkowl 7ebe125
Merge remote-tracking branch 'origin/develop' into hawkowl/pgtests
hawkowl f672092
hrhthg isort
hawkowl 799faca
revert
hawkowl b841dcf
fix
hawkowl 226cdf1
revert stuff
hawkowl bdd134a
try this instead
hawkowl 1f80f61
revert this too
hawkowl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The test suite now passes on PostgreSQL. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
|
||
from twisted.internet import defer | ||
|
||
from synapse.util.caches.descriptors import cached | ||
from synapse.util.caches.descriptors import cachedInlineCallbacks | ||
|
||
from ._base import SQLBaseStore | ||
|
||
|
@@ -29,7 +29,7 @@ | |
|
||
class MonthlyActiveUsersStore(SQLBaseStore): | ||
def __init__(self, dbconn, hs): | ||
super(MonthlyActiveUsersStore, self).__init__(None, hs) | ||
super(MonthlyActiveUsersStore, self).__init__(dbconn, hs) | ||
self._clock = hs.get_clock() | ||
self.hs = hs | ||
self.reserved_users = () | ||
|
@@ -131,21 +131,20 @@ def _reap_users(txn): | |
self.user_last_seen_monthly_active.invalidate_all() | ||
self.get_monthly_active_count.invalidate_all() | ||
|
||
@cached(num_args=0) | ||
@cachedInlineCallbacks(num_args=0) | ||
def get_monthly_active_count(self): | ||
"""Generates current count of monthly active users | ||
|
||
Returns: | ||
Defered[int]: Number of current monthly active users | ||
""" | ||
|
||
def _count_users(txn): | ||
sql = "SELECT COALESCE(count(*), 0) FROM monthly_active_users" | ||
|
||
txn.execute(sql) | ||
count, = txn.fetchone() | ||
return count | ||
return self.runInteraction("count_users", _count_users) | ||
res = yield self.runInteraction("count_users", _count_users) | ||
defer.returnValue(res) | ||
|
||
@defer.inlineCallbacks | ||
def upsert_monthly_active_user(self, user_id): | ||
|
@@ -171,7 +170,7 @@ def upsert_monthly_active_user(self, user_id): | |
self.user_last_seen_monthly_active.invalidate((user_id,)) | ||
self.get_monthly_active_count.invalidate(()) | ||
|
||
@cached(num_args=1) | ||
@cachedInlineCallbacks(num_args=1) | ||
def user_last_seen_monthly_active(self, user_id): | ||
""" | ||
Checks if a given user is part of the monthly active user group | ||
|
@@ -182,7 +181,7 @@ def user_last_seen_monthly_active(self, user_id): | |
|
||
""" | ||
|
||
return(self._simple_select_one_onecol( | ||
res = yield (self._simple_select_one_onecol( | ||
table="monthly_active_users", | ||
keyvalues={ | ||
"user_id": user_id, | ||
|
@@ -191,6 +190,7 @@ def user_last_seen_monthly_active(self, user_id): | |
allow_none=True, | ||
desc="user_last_seen_monthly_active", | ||
)) | ||
defer.returnValue(res) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for converting all these functions to defer.inlineCallbacks? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. me trying things and inadvertently committing it :) -- reverted |
||
|
||
@defer.inlineCallbacks | ||
def populate_monthly_active_users(self, user_id): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, fun fact: this now gets set on the slave replication stores as well as the store on master. This is a bit awkward because we do set
self._cache_id_gen
on the replication stores insynapse/replication/slave/storage/_base.py
to something different.In short, everything is awful and is scary and I'm scared about moving this here in case the replication stuff fail to properly overwrite this definition