File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
modules/module-mongodb/src/replication Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @powersync/service-module-mongodb ' : minor
3+ ---
4+
5+ Added progress logs to initial snapshot
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ export class ChangeStream {
164164
165165 async estimatedCount ( table : storage . SourceTable ) : Promise < string > {
166166 const db = this . client . db ( table . schema ) ;
167- const count = db . collection ( table . table ) . estimatedDocumentCount ( ) ;
167+ const count = await db . collection ( table . table ) . estimatedDocumentCount ( ) ;
168168 return `~${ count } ` ;
169169 }
170170
@@ -298,6 +298,7 @@ export class ChangeStream {
298298 logger . info ( `Replicating ${ table . qualifiedName } ` ) ;
299299 const estimatedCount = await this . estimatedCount ( table ) ;
300300 let at = 0 ;
301+ let lastLogIndex = 0 ;
301302
302303 const db = this . client . db ( table . schema ) ;
303304 const collection = db . collection ( table . table ) ;
@@ -310,8 +311,6 @@ export class ChangeStream {
310311 throw new ReplicationAbortedError ( `Aborted initial replication` ) ;
311312 }
312313
313- at += 1 ;
314-
315314 const record = constructAfterRecord ( document ) ;
316315
317316 // This auto-flushes when the batch reaches its size limit
@@ -325,6 +324,10 @@ export class ChangeStream {
325324 } ) ;
326325
327326 at += 1 ;
327+ if ( at - lastLogIndex >= 5000 ) {
328+ logger . info ( `[${ this . group_id } ] Replicating ${ table . qualifiedName } ${ at } /${ estimatedCount } ` ) ;
329+ lastLogIndex = at ;
330+ }
328331 Metrics . getInstance ( ) . rows_replicated_total . add ( 1 ) ;
329332
330333 await touch ( ) ;
You can’t perform that action at this time.
0 commit comments