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

switch back from GIST to GIN indexes #2769

Merged
merged 15 commits into from
Feb 14, 2018
Merged

switch back from GIST to GIN indexes #2769

merged 15 commits into from
Feb 14, 2018

Conversation

ara4n
Copy link
Member

@ara4n ara4n commented Jan 9, 2018

fixes #2753

def _background_reindex_gin_search(self, progress, batch_size):
'''This handles old synapses which used GIST indexes; converting them
back to be GIN as per the actual schema. Otherwise it crashes out
as a NOOP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the background reindexer handle things that crash?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I'm aware, it makes the updater get stuck in a loop, attempting to do the update every second forever.

this... sounds less than ideal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, but a66f489 was an attempt to fix this.

@erikjohnston
Copy link
Member

This won't work as a) you don't register the new background update in a new delta file and b) you've removed a delta update function without removing it from the delta files


conn.set_session(autocommit=False)
conn.set_session(autocommit=False)
except e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itym except Exception as e

People may have queued updates for this, so we can't just delete it.
... as a precursor to making event storing and doing the bg update share some
code.
Add some comments and improve exception handling when twiddling work_mem for
the search update
we can reuse the same code as is used for event insert, for doing the
background index population.
@richvdh
Copy link
Member

richvdh commented Feb 13, 2018

@erikjohnston please could you have another look at this? I suggest you start from scratch, rather than attempting to pick out the delta from your previous review.

We're up to schema v47 on develop now, so this will have to go in there to have
an effect.

This might cause an error if somebody has already run it in the v46 guise, and
runs it again in the v47 guise, because it will cause a duplicate entry in the
bbackground_updates table. On the other hand, the entry is removed once it is
complete, and it is unlikely that anyone other than matrix.org has run it on
v46. The update itself is harmless to re-run because it deliberately copes with
the index already existing.
@richvdh richvdh force-pushed the matthew/hit_the_gin branch from 8b8dab7 to ddb6a79 Compare February 13, 2018 16:45
txn.executemany(sql, args)
except Exception:
# we need to reset work_mem, but doing so may throw a new
# exception and we want to preserve the original
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we? work_mem should be reset if the transaction aborts: https://www.postgresql.org/docs/9.4/static/sql-set.html

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh. good point :/

@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Feb 14, 2018
@richvdh richvdh merged commit d28ec43 into develop Feb 14, 2018
@richvdh richvdh deleted the matthew/hit_the_gin branch February 14, 2018 16:59
@richvdh richvdh restored the matthew/hit_the_gin branch September 6, 2018 12:00
@hawkowl hawkowl deleted the matthew/hit_the_gin branch September 20, 2018 13:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants