Sync Gateway stopped sending changes

I’ve hit an issue so that Sync Gateway stopped sending changes after adding more data into the db when initial data was sent.
I am using _changes?feed=continuous on the gateway, connected to the Couchbase Server v. 5.1.0.

I’ve loaded ~25k documents into a bucket.
After that I’ve tested the sync gateway by calling _changes?feed=continuous.
The gateway sent all the data till the end of the bucket and after that it was still sending data properly when triggered via adding/modifying/removing documents. I was receiving new data using curl with _changes API and I was seeing in sync_gateway_error.log logs like the one below:
[INF] Changes: sending 1 change(s)

Then I’ve loaded another ~50k elements into the bucket.
After this Gateway I invoked again the rest API _changes?feed=continuous.
Gateway sent all the initial data from the bucket but somehow became kind of out of sync in the matter of sending the changes.
I can see in the logs that the Gateway notifies about the changes but it does not send them:

2019-06-14T06:34:23.663-05:00 [INF] Import: Created new rev ID 2-afb7bda1b2282c0ec2ffe8ae443ec307
2019-06-14T06:34:23.664-05:00 [INF] CRUD: Stored doc “17491.0.100001” / “2-afb7bda1b2282c0ec2ffe8ae443ec307”
2019-06-14T06:34:23.665-05:00 [INF] Cache: Received #23357 after 0ms (“17491.0.100001” / “2-afb7bda1b2282c0ec2ffe8ae443ec307”)

I’ve noticed also strange seq ids in the responses, after around 75k it became 373k:

Is there any chance that the sync gateway lost the seq id that it should track?
Is there any way to refresh it?

Restart of the sync gateway solves the issue and it starts syncing the data correctly.


It turned out that there was additional action made apart of adding new docs.
Flushing the bucket via web interface makes the SyncGateway out of sync.