PullReplication is not stoping once if it is started in android

60 views
Skip to first unread message

PRASANNA KUMAR

unread,
Oct 26, 2015, 9:01:29 AM10/26/15
to Couchbase Mobile
Hi All,

I have been working couch base lite android one of my project, I'm facing the problem while doing PullReplication, I started the replication but some where i need to stop it(That is my requirement(start/stop)). The replication started successfully but while stop the replication still it is running in background.

Note: Here is my code


Even if we are stoping  but still my replication status always showing active state not going to stop state

Can any body me out of here, How i can achieve this or any solutions for this problem

Thank's
prasanna
   

James Nocentini

unread,
Oct 26, 2015, 9:07:50 AM10/26/15
to Couchbase Mobile
What happens if you dereference the property like this:

pullReplication.stop();
pullReplication = nil;

James

PRASANNA KUMAR

unread,
Oct 27, 2015, 2:32:57 AM10/27/15
to Couchbase Mobile
Thank's you reply, Even i did
pullReplication.stop();
pullReplication = null;

This one also not working

PRASANNA KUMAR

unread,
Oct 27, 2015, 3:09:41 AM10/27/15
to Couchbase Mobile
I think background thread i running  in background,once replication is start.

PRASANNA KUMAR

unread,
Oct 27, 2015, 4:10:09 AM10/27/15
to Couchbase Mobile
Ok, Right now i have some log's information what is happing while doing replication(stop/start)

1) When start the replication it is successfully working (but i think some thing is wrong in showing the counts information i mean completedChangesCount and changesCount)
2) When i made the stop replication
pullReplication.stop();
pullReplication = null;

Here some of log information when i made stop the replication
3) Again i start the replication by the time my location database showing all documents in location
i mean serverDcouments == localDocuments(true) but replication status is

10-27 03:51:16.118  29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ REPLICATION_ACTIVE

Even not been idle.

I have few questions  about replication part
1) Is replication creating any thread in backgroup(for start/stop)
2) And also it taking more CPU resource while doing replication

How we can solve this problem.

Thank you
prasanna

Jens Alfke

unread,
Oct 27, 2015, 12:59:20 PM10/27/15
to mobile-c...@googlegroups.com

On Oct 26, 2015, at 6:07 AM, James Nocentini <james.n...@gmail.com> wrote:

What happens if you dereference the property like this:

pullReplication.stop();
pullReplication = nil;

Setting the variable to nil won’t affect anything except memory usage.

—Jens

Hideki Itakura

unread,
Oct 28, 2015, 12:56:42 AM10/28/15
to Couchbase Mobile
Hi PRASANNA,

Your code is fine. Replication.stop() does not stop immediately. If downloading tasks remain in the queue, the replicator will stop after processed these tasks.

Thanks,
Hideki

Hideki Itakura

unread,
Oct 28, 2015, 1:02:58 AM10/28/15
to Couchbase Mobile
> 1) Is replication creating any thread in backgroup(for start/stop)

Yes, Couchbase Lite creates single thread which manages replication. In addition to this thread, Couchbase Lite creates multiple thread for downloading tasks. 

> 2) And also it taking more CPU resource while doing replication

If the replicator needs to process many documents or large documents, it might consume CPU and memory.

Thanks,
Hideki

Pasin Suriyentrakorn

unread,
Oct 28, 2015, 1:59:45 PM10/28/15
to Couchbase Mobile
@hideki, from @prasanna's log, I have noticed one thing that there are a lot of notifications without status changes. Is this normal?

10-27 03:50:21.730 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ Replicator processed 0 / 23
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ REPLICATION_ACTIVE
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ Replicator processed 0 / 23
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ REPLICATION_ACTIVE
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ Replicator processed 0 / 23
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ REPLICATION_ACTIVE
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ Replicator processed 0 / 23
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ REPLICATION_ACTIVE
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ Replicator processed 0 / 23
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ REPLICATION_ACTIVE
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ Replicator processed 0 / 23
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ REPLICATION_ACTIVE
10-27 03:50:21.731 29387-29612/com.edcontrol.edcontrols D/Testing replication﹕ Replicator processed 0 / 23

Hideki Itakura

unread,
Oct 28, 2015, 7:28:58 PM10/28/15
to mobile-c...@googlegroups.com
Hi @pasin,
Notification should be fired only when some status changes. As you mentioned, it is not normal.

--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/ItktPXTY4nA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/7baa889e-1ced-4eed-9ec5-2a580effa530%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Thanks,
Hideki Itakura

PRASANNA KUMAR

unread,
Oct 29, 2015, 2:43:51 AM10/29/15
to Couchbase Mobile
@Hideki Itakura and @jens, both you thanks for such nice explanation.

@Hideki Itakura: I have question for you(I would like to know more about that part)


But other platforms stop is working immediately, I think is that problem for only android. And I do not think show replication is stoping after some time(When we did stop).

Let me explain small example. I have server database with 250 documents, I did start replication and there i've made a one condition if local document is more 20 than i'm forcefully stoping that replication. after 3 to 5 min i started again than my replication status is showing idle and location database document count also 250 than i wonder about that. There is one more highlighting point is once i stop the replication conditions there if(replication.isRunning) is showing !!false and if(replication.getStatus) is showing !!Replication_Active where i have little confusion about how process will work(i think, it should be when replication is not running than status also should be Replication_Stop).
And also as you mention that 
Replication.stop() does not stop immediately. If downloading tasks remain in the queue, the replicator will stop after processed these tasks.

1) What do you mean about "If downloading tasks remain in the queue" this point view.
2) And any suggestion of when we large database(4000 documents and all) when looking forward for performance.

I would like to thanks again both of you!!

Hideki Itakura

unread,
Oct 29, 2015, 3:17:33 PM10/29/15
to mobile-c...@googlegroups.com
Hi PRASANNA,

1) What do you mean about "If downloading tasks remain in the queue" this point view.

After starting the pull replication, the pull replicator receives list of changes (gap between server and local) from Sync Gateway (or CouchDB). The replicator put  changes in queue, and creates tasks to download each change. Then download tasks will be executed in order. After calling replicator.stop(), the replicator waits till tasks queue is empty. This is reason that stop() does not stop replicator immediately. (Note: As I don't re-read codes, so my explanation might be little different .)

2) And any suggestion of when we large database(4000 documents and all) when looking forward for performance.

Since v1.1, I believe CBL Java/Android replication performance is good enough. If each document size is not too big, replicating 4000 documents could be done in reasonable time. Also the replicator is not using main thread, so it does not block other stuff.

Thanks,
Hideki


--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/ItktPXTY4nA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

PRASANNA KUMAR

unread,
Oct 30, 2015, 1:13:37 AM10/30/15
to Couchbase Mobile
Hi Hideki Itakura,

Thank's for such a Wonderfull explanation.
Reply all
Reply to author
Forward
0 new messages