-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Regression in replicateTo method. #5157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I have remote CouchDB with 30_000 docs. I replicateFrom all docs. But(!) replicateTo 'paused' events not trigger. And I see than pouchdb every seconds send _bulk_docs, _local and _revs_diff to CouchDB and I see in CouchDB {"_id":"_local/VfNqh5fhbhdOCfRFn8pEmA==","_rev":"0-675","session_id":"4241BF48-47C3-5446-B3FE-F329644B5F2E","history":[{"last_seq":675,"session_id":"4241BF48-47C3-5446-B3FE-F329644B5F2E"}],"replicator":"pouchdb","version":1,"last_seq":675} where last_seq increments by one. After last_seq = 30_000 'paused' events in replicateTo is triggered. But when revert batches.length === 0 'paused' events trigger immediately as expected.
But, I have question number 2: why pouchdb send every second _bulk_docs, _local and _revs_diff to CouchDB?? And i See in CouchDB log: {"_id":"_local/VfNqh5fhbhdOCfRFn8pEmA==","_rev":"0-675","session_id":"4241BF48-47C3-5446-B3FE-F329644B5F2E","history":[{"last_seq":675,"session_id":"4241BF48-47C3-5446-B3FE-F329644B5F2E"}],"replicator":"pouchdb","version":1,"last_seq":675} where last_seq increments by one ??? I'm not create any docs locally in pouch. All docs was replicated from remote CouchDB. Oh... my head...
|
I got it. batch_size not work when processPendingBatch(changesOpts.live); And in reverted variant batch_size default = 1, but I may change this option and it's work. |
|
@man4j Hi, thanks for the PR, it looks like there are failures in this fix, I am having a little problem understanding what your bug is. You say you see |
|
@daleharvey At this moment bug in batch_size parameter. In current version batch_size = 1 and not configurable ((( Please fix this bug. ReplicateTo method very slow, because batch_size = 1 and it's send many requests to CouchDB. But my fix maybe is not fully correct, but batch_size is work (but default whatever = 1, but I may configure it). |
|
In the changes feed the default batch_size is 25 and can be configured https://github.com/pouchdb/pouchdb/blob/master/src/adapters/http/index.js#L712, in replication the default batch size is 100 and also configurable https://github.com/pouchdb/pouchdb/blob/master/src/replicate/replicate.js#L23 Can you clarify the problem in terms of the behaviour you are seeing, is the entire problem that replication is too slow / using lots of requests? or are you seeing functional bugs? again example code would be really useful |
|
@daleharvey Ok, this is my example: Very easy, right? And if i open couchdb log (http://kaizen-retail.com:5984/_log?bytes=10000) i see 2 interesting urls: GET /test_bug_db/_local/7ERAWapZlPnVyIZ6T5LL8w%3D%3D? 200 And i copy this urls in my browser, and i see: By first url: (replicateTo) By second url: (replicateFrom) Please, fix this bug. |
|
I have the exact same issue. See #5167 I didn't notice this pull request until just now... your fix definitely resolves my issue. Check out the commit that introduced this issue. Specifically the test... I'm a little suspicious of the comparison added: Is |
|
Also, it appears you are just resetting this commit without updating the tests that were committed with that 1 line of source change. |
|
Looking at PR #4753 , So could we simply change:
to satisfy both continuous (i.e. @man4j Could you try this and see how the tests go ? |
|
Yes, it's fixes a bug. I'm very happy! Thanks! |
|
This PR is failing for the |
|
Well, I tried to replicate this issue in a unit test, and I admit I'm unable to: f289d50. However, I did try out @man4j 's test case, and I can agree that there are serious performance problems with replicating from the given CouchDB server, which I am unable to replicate locally because it probably involves failed requests across the network (and hence I cannot repro with localhost). What I'm seeing a lot of is this: I.e. the browser is being starved because we're making many many simultaneous GET requests, of which the majority are canceled. Then it tries again. All the while, the UI is running very slowly because the concurrent Ajax requests are starving the UI thread. I think this is another issue that requires its own fix (throttle network requests in the |
|
#5195 attempts to address the starvation issue, but we'd still need a repro for the |
|
closing in favor of #5196, please move discussion over there |

I have remote CouchDB with 30_000 docs. I replicateFrom all docs. But(!) replicateTo 'paused' events not trigger. And I see than pouchdb every seconds send _bulk_docs, _local and _revs_diff to CouchDB and I see in CouchDB
{ "_id":"_local/VfNqh5fhbhdOCfRFn8pEmA==", "_rev":"0-675", "session_id":"4241BF48-47C3-5446-B3FE-F329644B5F2E", "history":[ { "last_seq":675, "session_id":"4241BF48-47C3-5446-B3FE-F329644B5F2E" } ], "replicator":"pouchdb", "version":1, "last_seq":675 }where last_seq increments by one. After last_seq = 30_000 'paused' events in replicateTo is triggered. But when revert batches.length === 0 'paused' events trigger immediately as expected.
But, I have question number 2: why pouchdb send every second _bulk_docs, _local and _revs_diff to CouchDB?? And i See in CouchDB log:
{ "_id":"_local/VfNqh5fhbhdOCfRFn8pEmA==", "_rev":"0-675", "session_id":"4241BF48-47C3-5446-B3FE-F329644B5F2E", "history":[ { "last_seq":675, "session_id":"4241BF48-47C3-5446-B3FE-F329644B5F2E" } ], "replicator":"pouchdb", "version":1, "last_seq":675 }where last_seq increments by one ??? I'm not create any docs locally in pouch. All docs was replicated from remote CouchDB. Oh... my head... Thanks!