Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
process_fts_updates: After getting notifies, process them all.
Alex Vandivereeb485f89447
diff --git a/puppet/zulip/files/postgresql/process_fts_updates b/puppet/zulip/files/postgresql/process_fts_updatesindex f8eecfbb183..4da7c310f24 100755--- a/puppet/zulip/files/postgresql/process_fts_updates+++ b/puppet/zulip/files/postgresql/process_fts_updates@@ -91,6 +91,23 @@ def update_fts_columns(conn: psycopg2.extensions.connection) -> int:return len(ids)+def update_all_rows(msg: str, conn: psycopg2.extensions.connection) -> None:+ while True:+ start_time = time.perf_counter()+ rows_updated = update_fts_columns(conn)+ if rows_updated:+ logger.log(+ logging.INFO,+ "process_fts_updates: %s %d rows, %d rows/sec",+ msg,+ rows_updated,+ rows_updated / (time.perf_counter() - start_time),+ )++ if rows_updated != BATCH_SIZE:+ return++def am_master(conn: psycopg2.extensions.connection) -> bool:with conn.cursor() as cursor:cursor.execute("SELECT pg_is_in_recovery()")@@ -223,24 +240,14 @@ while True:conn.commit()# Catch up on any historical columns- while True:- rows_updated = update_fts_columns(conn)- logger.log(- logging.INFO if rows_updated > 0 else logging.DEBUG,- "process_fts_updates: Processed %d rows catching up",- rows_updated,- )-- if rows_updated != BATCH_SIZE:- # We're caught up, so proceed to the listening for updates phase.- break+ update_all_rows("Caught up", conn)# TODO: If we go back into recovery, we should stop processing updatesif select.select([conn], [], [], 30) != ([], [], []):conn.poll()- while conn.notifies:- conn.notifies.pop()- update_fts_columns(cursor)+ conn.notifies.clear()+ update_all_rows("Updated", conn)+except psycopg2.OperationalError as e:retries -= 1if retries <= 0: