From 768934e1ccbfa23619b1934e79df7c0eefe8a9e2 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 8 Jul 2021 14:29:47 -0400 Subject: [PATCH] skip es sync during initial hub sync, halt the hub upon finishing initial sync --- lbry/wallet/server/block_processor.py | 11 ++++++----- lbry/wallet/server/server.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lbry/wallet/server/block_processor.py b/lbry/wallet/server/block_processor.py index bdc301be5..9c9734774 100644 --- a/lbry/wallet/server/block_processor.py +++ b/lbry/wallet/server/block_processor.py @@ -172,11 +172,12 @@ class BlockProcessor: "reorg_count", "Number of reorgs", namespace=NAMESPACE ) - def __init__(self, env, db: 'LevelDB', daemon, notifications): + def __init__(self, env, db: 'LevelDB', daemon, notifications, shutdown_event: asyncio.Event): self.env = env self.db = db self.daemon = daemon self.notifications = notifications + self.shutdown_event = shutdown_event self.coin = env.coin if env.coin.NET == 'mainnet': @@ -308,7 +309,8 @@ class BlockProcessor: await self.run_in_thread_with_lock(self.advance_block, block) self.logger.info("advanced to %i in %0.3fs", self.height, time.perf_counter() - start) # TODO: we shouldnt wait on the search index updating before advancing to the next block - await self.db.search_index.claim_consumer(self.claim_producer()) + if not self.db.first_sync: + await self.db.search_index.claim_consumer(self.claim_producer()) self.db.search_index.clear_caches() self.touched_claims_to_send_es.clear() self.removed_claims_to_send_es.clear() @@ -1495,9 +1497,8 @@ class BlockProcessor: await self.flush(True) if first_sync: self.logger.info(f'{lbry.__version__} synced to ' - f'height {self.height:,d}') - # Reopen for serving - await self.db.open_dbs() + f'height {self.height:,d}, halting here.') + self.shutdown_event.set() # --- External API diff --git a/lbry/wallet/server/server.py b/lbry/wallet/server/server.py index cbec5c93b..bad970c78 100644 --- a/lbry/wallet/server/server.py +++ b/lbry/wallet/server/server.py @@ -76,7 +76,7 @@ class Server: self.notifications = notifications = Notifications() self.daemon = daemon = env.coin.DAEMON(env.coin, env.daemon_url) self.db = db = env.coin.DB(env) - self.bp = bp = env.coin.BLOCK_PROCESSOR(env, db, daemon, notifications) + self.bp = bp = env.coin.BLOCK_PROCESSOR(env, db, daemon, notifications, self.shutdown_event) self.prometheus_server: typing.Optional[PrometheusServer] = None # Set notifications up to implement the MemPoolAPI