synapse/storage/search.py
def _background_reindex_gin_search(self, progress, batch_size):
        """This handles old synapses which used GIST indexes, if any;
        converting them back to be GIN as per the actual schema.
        """

        def create_index(conn):
            conn.rollback()

            # we have to set autocommit, because postgres refuses to
            # CREATE INDEX CONCURRENTLY without it.
            conn.set_session(autocommit=True)

            try:
                c = conn.cursor()

                # if we skipped the conversion to GIST, we may already/still
                # have an event_search_fts_idx; unfortunately postgres 9.4
                # doesn't support CREATE INDEX IF EXISTS so we just catch the
                # exception and ignore it.
                import psycopg2
                try:
                    c.execute(
                        "CREATE INDEX CONCURRENTLY event_search_fts_idx"
                        " ON event_search USING GIN (vector)"
                    )
                except psycopg2.ProgrammingError as e:
                    logger.warn(
                        "Ignoring error %r when trying to switch from GIST to GIN",
                        e
                    )

                # we should now be able to delete the GIST index.
                c.execute(
                    "DROP INDEX IF EXISTS event_search_fts_idx_gist"
                )
            finally:
                conn.set_session(autocommit=False)

        if isinstance(self.database_engine, PostgresEngine):
            yield self.runWithConnection(create_index)

        yield self._end_background_update(self.EVENT_SEARCH_USE_GIN_POSTGRES_NAME)
        defer.returnValue(1)
This handles old synapses which used GIST indexes, if any;
        converting them back to be GIN as per the actual schema.
        
This handles old synapses which used GIST indexes, if any;
converting them back to be GIN as per the actual schema.
This handles old synapses which used GIST indexes if any ; converting them back to be GIN as per the actual schema .
def _background_reindex_gin_search(self, progress, batch_size):
        def create_index(conn):
            conn.rollback()
            conn.set_session(autocommit=True)
            try:
                c = conn.cursor()
                import psycopg2
                try:
                    c.execute(
                        "CREATE INDEX CONCURRENTLY event_search_fts_idx"
                        " ON event_search USING GIN (vector)"
                    )
                except psycopg2.ProgrammingError as e:
                    logger.warn(
                        "Ignoring error %r when trying to switch from GIST to GIN",
                        e
                    )
                c.execute(
                    "DROP INDEX IF EXISTS event_search_fts_idx_gist"
                )
            finally:
                conn.set_session(autocommit=False)
        if isinstance(self.database_engine, PostgresEngine):
            yield self.runWithConnection(create_index)
        yield self._end_background_update(self.EVENT_SEARCH_USE_GIN_POSTGRES_NAME)
        defer.returnValue(1)
def _background_reindex_gin_search ( self , progress , batch_size ) : def create_index ( conn ) : conn . rollback ( ) conn . set_session ( autocommit = True ) try : c = conn . cursor ( ) import psycopg2 try : c . execute ( "CREATE INDEX CONCURRENTLY event_search_fts_idx" " ON event_search USING GIN (vector)" ) except psycopg2 . ProgrammingError as e : logger . warn ( "Ignoring error %r when trying to switch from GIST to GIN" , e ) c . execute ( "DROP INDEX IF EXISTS event_search_fts_idx_gist" ) finally : conn . set_session ( autocommit = False ) if isinstance ( self . database_engine , PostgresEngine ) : yield self . runWithConnection ( create_index ) yield self . _end_background_update ( self . EVENT_SEARCH_USE_GIN_POSTGRES_NAME ) defer . returnValue ( 1 )
This handles old synapses which used GIST indexes, if any;
converting them back to be GIN as per the actual schema.
This handles old synapses which used GIST indexes if any ; converting them back to be GIN as per the actual schema .
"""This handles old synapses which used GIST indexes, if any;
        converting them back to be GIN as per the actual schema.
        """ # we have to set autocommit, because postgres refuses to # CREATE INDEX CONCURRENTLY without it. # if we skipped the conversion to GIST, we may already/still # have an event_search_fts_idx; unfortunately postgres 9.4 # doesn't support CREATE INDEX IF EXISTS so we just catch the # exception and ignore it. # we should now be able to delete the GIST index.
self
progress
batch_size