Are filtered replication rules saved locally and run everytime in TouchDB-iOS without being explicitly invoked?

39 views
Skip to first unread message

Pulkit Singhal

unread,
Nov 13, 2012, 1:43:28 PM11/13/12
to mobile-c...@googlegroups.com

Hello Jens,

Are filtered replication rules saved locally and run every time in TouchDB-iOS on launch without being explicitly invoked?

I ask because I changed the name of the database both locally and remotely in my test app but the older database still showed up in the logs attempting to replicate:

// the following log starts out fine
2012-11-13 12:17:21.531 [3489:707] Creating database...
2012-11-13 12:17:22.155 [3489:707] ...Created CouchDatabase at <touchdb:///new_db_name>

// then the it becomes troubling because I'm NOT invoking the creation or replication on the local old_db_name anymore:
12:17:37.541| ChangeTracker: TDConnectionChangeTracker[0xaeafa0 old_db_name]: Started...
<https://username:pass...@couchdb.com./old_db_name/_changes?feed=normal&heartbeat=300000&style=all_docs&since=5744&limit=100&filter=default/myFilter>
12:17:53.472| ChangeTracker: TDConnectionChangeTracker[0xaeafa0 old_db_name]: Started...
<https://username:pass...@couchdb.com./old_db_name/_changes?feed=longpoll&heartbeat=300000&style=all_docs&since=5744&limit=100&filter=default/myFilter>
2012-11-13 12:17:53.478 [3489:4803] CouchTouchDBServer[touchdb:///]: Replication progress changed
2012-11-13 12:17:54.750 [3489:707] CouchPersistentReplication[DF10..937B] = (null)
2012-11-13 12:17:54.755 [3489:707] CouchPersistentReplication[04AC..91D3] = (null)
2012-11-13 12:17:54.837 [3489:707] >>>>>> 1 docs being updated
2012-11-13 12:17:55.008 [3489:707] >>>>>> 2 docs being updated
2012-11-13 12:17:55.039 [3489:707] CouchLiveQuery: ...Finished (status=200)
2012-11-13 12:17:55.041 [3489:707] CouchLiveQuery: ...Rows changed! (now 0)
2012-11-13 12:17:55.046 [3489:707] <<<<<< 1 docs being updated

// then the logs go back to stuff that makes sense to me again with the use of new_db_name:

12:17:55.359| ChangeTracker: TDConnectionChangeTracker[0xe88a8e0 new_db_name]: Started...
<https://username:pass...@couchdb.com./new_db_name/_changes?feed=normal&heartbeat=300000&style=all_docs&limit=100&filter=default/clientFilter>
12:17:55.747| ChangeTracker: TDConnectionChangeTracker[0xe88a8e0 new_db_name]: Got response, status 200
12:17:55.748| ChangeTracker: TDConnectionChangeTracker[0xe88a8e0 new_db_name]: Got entire body, 519 bytes
12:17:55.753| ChangeTracker: TDConnectionChangeTracker[0xe88a8e0 new_db_name]: Started...
<https://username:pass...@couchdb.com./new_db_name/_changes?feed=longpoll&heartbeat=300000&style=all_docs&since=7&limit=100&filter=default/clientFilter>
2012-11-13 12:17:55.759 [3489:4803] CouchTouchDBServer[touchdb:///]: Replication progress changed
2012-11-13 12:17:57.545 [3489:707] **** CHANGE #1: CouchDocument[org...list]  (null) -> 1-a4bc57ce5f81412e3332e14eccdd70a1
2012-11-13 12:17:57.559 [3489:707] **** CHANGE #2: CouchDocument[org...stry]  (null) -> 1-398151a37daf892abab50f7f32671e6a
2012-11-13 12:17:57.567 [3489:707] **** CHANGE #3: CouchDocument[20d0..316f]  (null) -> 1-8359ef1157849d18dba30504383142fe
2012-11-13 12:17:57.579 [3489:707] **** CHANGE #4: CouchDocument[20d0..3442]  (null) -> 1-fc681b6bdcce75cc55f390191eb7ce74
2012-11-13 12:17:57.581 [3489:707] CouchDatabase: External change with seq=4

// and then they go back to confusing again with the use of old_db_name:

12:18:32.257| TDRemoteJSONRequest
[GET https://username:pass...@couchdb.com/old_db_name/_local/ca8c016b72014ab703183af1f3be99d9bbc6e8e0]:
Got error Error Domain=NSURLErrorDomain
Code=-1001
"The request timed out."
UserInfo=0xac3350 {NSErrorFailingURLStringKey=https://username:pass...@couchdb.com/old_db_name/_local/ca8c016b72014ab703183af1f3be99d9bbc6e8e0, NSErrorFailingURLKey=https://username:pass...@couchdb.com/old_db_name/_local/ca8c016b72014ab703183af1f3be99d9bbc6e8e0,
NSLocalizedDescription=The request timed out.,
NSUnderlyingError=0xe9925f0 "The request timed out."}


Is this all standard procedure?
If so, then how can I prevent an existing DB from replicating if I didn't invoke it explicitly on my test app's startup?

Thanks!
- Pulkit

Jens Alfke

unread,
Nov 13, 2012, 7:39:27 PM11/13/12
to mobile-c...@googlegroups.com

On Nov 13, 2012, at 10:43 AM, Pulkit Singhal <pulkit...@gmail.com> wrote:

Are filtered replication rules saved locally and run every time in TouchDB-iOS on launch without being explicitly invoked?

Persistent replications are, as the name implies, stored locally (in a special database named _replicator.) The info saved is the name of the local database, the URL of the remote db, flags like ‘continuous’, etc.

I ask because I changed the name of the database both locally and remotely in my test app but the older database still showed up in the logs attempting to replicate:

How did you ‘change the name’ of the database? There’s no API for that :-/ If you went into the filesystem and renamed the database file, the replicator’s not going to know about that, so the replication document will still have the old name init.

—Jens

Pulkit Singhal

unread,
Nov 14, 2012, 7:21:26 PM11/14/12
to mobile-c...@googlegroups.com
How did you ‘change the name’ of the database? There’s no API for that :-/ If you went into the filesystem and renamed the database file, the replicator’s not going to know about that, so the replication document will still have the old name init.

I decided that for my test app I needed to separate out the data generated while testing my DEBUG builds with developers and my ADHOC builds with beta testers. So instead of using the standard db_name I added debug_db_name and adhoc_db_name to my CouchDB and wired the test app's code to select/initialize/replicate with the correct one based on #if DEBUG and #if ADHOC flags for condinational compilation. I knew that this doesn't mean that the db_name that was already present just evaporates ... but I simply wasn't expecting it to try and replicate on its own, that's all.

Thanks for the info Jens :)
- Pulkit
Reply all
Reply to author
Forward
0 new messages