@@ -43,21 +43,24 @@ impl<IO: Io> Replicator<IO> {
4343 pub fn frame_stream ( & mut self ) -> impl Stream < Item = Result < Box < Frame > > > + ' _ {
4444 async_stream:: try_stream! {
4545 loop {
46+ // First we decide up to what frame_no we want to replicate in this step. If we are
47+ // already up to date, wait for something to happen
4648 let most_recent_frame_no = * self
4749 . new_frame_notifier
4850 . wait_for( |fno| * fno > self . next_frame_no)
4951 . await
5052 . expect( "channel cannot be closed because we hold a ref to the sending end" ) ;
5153
5254 let mut commit_frame_no = 0 ;
55+ // we have stuff to replicate
5356 if most_recent_frame_no > self . next_frame_no {
57+ // first replicate the most recent version of each page from the current
58+ // segment. We also return how far we have replicated from the current log
5459 let current = self . shared. current. load( ) ;
5560 let mut seen = RoaringBitmap :: new( ) ;
5661 let ( stream, replicated_until, size_after) = current. frame_stream_from( self . next_frame_no, & mut seen) ;
5762 let should_replicate_from_tail = replicated_until != self . next_frame_no;
5863
59-
60- // replicate from current
6164 {
6265 tokio:: pin!( stream) ;
6366
@@ -76,8 +79,8 @@ impl<IO: Io> Replicator<IO> {
7679 }
7780 }
7881
79-
80- // replicate from tail
82+ // Replicating from the current segment wasn't enough to bring us up to date,
83+ // wee need to take frames from the sealed segments.
8184 if should_replicate_from_tail {
8285 let replicated_until = {
8386 let ( stream, replicated_until) = current
@@ -104,6 +107,8 @@ impl<IO: Io> Replicator<IO> {
104107 should_replicate_from_storage. then_some( replicated_until)
105108 } ;
106109
110+ // Replicating from sealed segments was not enough, so we replicate from
111+ // durable storage
107112 if let Some ( replicated_until) = replicated_until {
108113 let stream = self
109114 . shared
0 commit comments