Where should an NNTP reader resume?
A missing row and a dropped connection need different checkpoints. How to keep an incremental newsgroup index consistent across gaps, restarts and provider changes.
Imagine a reader indexing headers for a local archive. It has finished article number 800 and requests the next hundred. Ninety rows arrive. Can it resume at 901? The answer depends on the last line the server sent.
Two ways to receive ninety rows
After selecting the group with GROUP, a reader on a server advertising OVER can request OVER 801-900. The numbers belong to that group on that server. Gaps are normal, and the count reported by GROUP is an estimate.
Cap each requested interval at the high water mark returned by that GROUP command. Our example assumes it was at least 900. With a high water mark of 850, stop at 850 and issue GROUP again on the next poll. Recording an empty range through 900 could skip future arrivals numbered 851–900. RFC 3977, GROUP
Suppose the server replies 224, sends ninety overview rows ending at number 890, then sends a line containing only a dot. That dot completes the response. The scan has covered the requested interval through 900. If the socket instead closes after row 890 and before the dot, the reader has no way to tell how many rows were still in flight. A third outcome, a range request answered with 423, means there were no articles in the interval when the server answered. RFC 3977, OVER
Commit the interval with the rows
For a small index backed by SQLite, one practical approach is to buffer a bounded batch until the reply is complete. In one transaction, store its rows and advance the checkpoint to the requested upper bound. An empty interval confirmed by 423 can advance the same checkpoint. After an interrupted reply, reconnect, select the group again, and retry from the previous checkpoint. A crash during the database transaction leaves either the old state or the completed batch. SQLite transaction guarantees
Keep two kinds of identity in the index. The tuple of server, group and article number locates an appearance in a spool. The Message-ID identifies the article across groups and servers. A cross-post can therefore have one article record and several group entries. A new provider gets its own checkpoint even when the group name matches. RFC 5536, Message-ID
What about a hole that fills tomorrow?
A server may reinstate an article under its previous number. A forward scan that has reached 900 will miss a reinstatement at 895. If recent reinstatements matter to your archive, periodically reread a trailing interval and merge its rows by identity. The width of that interval determines how far back you can notice a change. Keep that sweep’s progress separate from the forward checkpoint. RFC 3977, changes after GROUP
Try disconnecting a test reader one row before the final dot. After restart it should request 801–900 again. Then let a sparse response finish normally. This time the next forward request should start at 901, even if the last article returned was 890.