Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Don't fetch state for missing events that we fetched #2170

Merged
merged 4 commits into from May 3, 2017

Conversation

Projects
None yet
2 participants
Owner

erikjohnston commented Apr 28, 2017

After fetching missing events we didn't update the list of events that were missing, so while we did successfully fetch the missing events it still thought it had a hole. This meant that it fetched the state, which adds delays, CPU time and increased DB usage (since we don't delta encode those state sets)

Member

richvdh commented Apr 28, 2017 edited

For the record, this was introduced in synapse 0.20, in 3406333

@erikjohnston: the intention was that _get_missing_events_for_pdu returns the new value for have_seen. It might well make more sense for the call to have_events to be where you have put it, but in that case you can remove the redundant call in _get_missing_events_for_pdu.

@richvdh richvdh assigned erikjohnston and unassigned richvdh Apr 28, 2017

Owner

erikjohnston commented Apr 28, 2017

I think its more explicit to have it done in the outer function. WIll remove from _get_missing

@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Apr 28, 2017

- )
- else:
- logger.info("Found all missing prev events for %s", pdu.event_id)
- defer.returnValue(have_seen)
@richvdh

richvdh Apr 28, 2017

Member

there are other calls to defer.returnValue in this function; please update them too

also please update the docstring.

@richvdh

richvdh Apr 28, 2017

Member

while you're in there, the docstring claims that prevs should be a list, which looks like a lie. my fault, but could you fix it?

synapse/handlers/federation.py
+ [ev for ev, _ in pdu.prev_events]
+ )
+
+ seen = set(have_seen.keys())
@richvdh

richvdh May 2, 2017

Member

well, it looks very similar to me. what's the difference?

@erikjohnston

erikjohnston May 2, 2017

Owner

have_seen has been updated the line above, and have_seen needs to be rechecked as we just fetched some missing events. Is that what you mean? Or do you mean we should wrap the call to have_seen and seen in a function?

synapse/handlers/federation.py
+ # Update the set of things we've seen after trying to
+ # fetch the missing stuff
+ have_seen = yield self.store.have_events(
+ [ev for ev, _ in pdu.prev_events]
@richvdh

richvdh Apr 28, 2017

Member

use prevs here?

@richvdh richvdh assigned erikjohnston and unassigned richvdh Apr 28, 2017

@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Apr 28, 2017

still unclear why it looks like we're duplicating code here

@richvdh richvdh assigned erikjohnston and unassigned richvdh May 2, 2017

@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston May 2, 2017

Owner

erikjohnston commented May 2, 2017

I am completely failing to understand what you mean I'm afraid :(

@erikjohnston erikjohnston assigned erikjohnston and unassigned richvdh May 3, 2017

@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston May 3, 2017

richvdh approved these changes May 3, 2017

this is a horrible, horrible bit of code

but I think it looks ok now

@richvdh richvdh assigned erikjohnston and unassigned richvdh May 3, 2017

@erikjohnston erikjohnston merged commit 0c27383 into develop May 3, 2017

7 of 8 checks passed

Sytest Dendron (Merged PR) Build finished.
Details
Sytest Dendron (Commit) Build #2056 origin/erikj/fed_hole_state succeeded in 9 min 38 sec
Details
Sytest Postgres (Commit) Build #2889 origin/erikj/fed_hole_state succeeded in 6 min 39 sec
Details
Sytest Postgres (Merged PR) Build finished.
Details
Sytest SQLite (Commit) Build #2956 origin/erikj/fed_hole_state succeeded in 5 min 25 sec
Details
Sytest SQLite (Merged PR) Build finished.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

psaavedra added a commit to psaavedra/synapse that referenced this pull request May 19, 2017

Merge tag 'v0.21.0' into v0.21.0_no_federate_by_default
Changes in synapse v0.21.0 (2017-05-18)
=======================================

No changes since v0.21.0-rc3

Changes in synapse v0.21.0-rc3 (2017-05-17)
===========================================

Features:

* Add per user rate-limiting overrides (PR #2208)
* Add config option to limit maximum number of events requested by ``/sync``
  and ``/messages`` (PR #2221) Thanks to @psaavedra!

Changes:

* Various small performance fixes (PR #2201, #2202, #2224, #2226, #2227, #2228,
  #2229)
* Update username availability checker API (PR #2209, #2213)
* When purging, don't de-delta state groups we're about to delete (PR #2214)
* Documentation to check synapse version (PR #2215) Thanks to @hamber-dick!
* Add an index to event_search to speed up purge history API (PR #2218)

Bug fixes:

* Fix API to allow clients to upload one-time-keys with new sigs (PR #2206)

Changes in synapse v0.21.0-rc2 (2017-05-08)
===========================================

Changes:

* Always mark remotes as up if we receive a signed request from them (PR #2190)

Bug fixes:

* Fix bug where users got pushed for rooms they had muted (PR #2200)

Changes in synapse v0.21.0-rc1 (2017-05-08)
===========================================

Features:

* Add username availability checker API (PR #2183)
* Add read marker API (PR #2120)

Changes:

* Enable guest access for the 3pl/3pid APIs (PR #1986)
* Add setting to support TURN for guests (PR #2011)
* Various performance improvements (PR #2075, #2076, #2080, #2083, #2108,
  #2158, #2176, #2185)
* Make synctl a bit more user friendly (PR #2078, #2127) Thanks @APwhitehat!
* Replace HTTP replication with TCP replication (PR #2082, #2097, #2098,
  #2099, #2103, #2014, #2016, #2115, #2116, #2117)
* Support authenticated SMTP (PR #2102) Thanks @DanielDent!
* Add a counter metric for successfully-sent transactions (PR #2121)
* Propagate errors sensibly from proxied IS requests (PR #2147)
* Add more granular event send metrics (PR #2178)

Bug fixes:

* Fix nuke-room script to work with current schema (PR #1927) Thanks
  @zuckschwerdt!
* Fix db port script to not assume postgres tables are in the public schema
  (PR #2024) Thanks @jerrykan!
* Fix getting latest device IP for user with no devices (PR #2118)
* Fix rejection of invites to unreachable servers (PR #2145)
* Fix code for reporting old verify keys in synapse (PR #2156)
* Fix invite state to always include all events (PR #2163)
* Fix bug where synapse would always fetch state for any missing event (PR #2170)
* Fix a leak with timed out HTTP connections (PR #2180)
* Fix bug where we didn't time out HTTP requests to ASes  (PR #2192)

Docs:

* Clarify doc for SQLite to PostgreSQL port (PR #1961) Thanks @benhylau!
* Fix typo in synctl help (PR #2107) Thanks @HarHarLinks!
* ``web_client_location`` documentation fix (PR #2131) Thanks @matthewjwolff!
* Update README.rst with FreeBSD changes (PR #2132) Thanks @feld!
* Clarify setting up metrics (PR #2149) Thanks @encks!

@erikjohnston erikjohnston deleted the erikj/fed_hole_state branch Oct 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment