Delay in opening database after encryption or decryption

8 views
Skip to first unread message

Brendan Duddridge

unread,
Sep 18, 2015, 1:46:59 AM9/18/15
to Couchbase Mobile
Hi,

Does CBL re-generate all the views after you've encrypted or decrypted the database?

I find that after I encrypt or decrypt, the next time I open the database, it takes a while to open the database. Subsequent opens are quick.

Logging shows a lot of output like this:

23:41:39.244| CBLDatabase: ForestDB: **** update: realKey = [["Tap Forms Developers"],"rec-1E774FB1A41948ACACA55A8A7EC0D5A5"]

23:41:39.244| CBLDatabase: ForestDB: DB 0x10128b930: added 070706562f4d043a4b5147530436375937454b4d3751530000065137330826382c2c293a32263029262e292d30343034302a2a302d302c383425362a302a0000 --> 0705408a58000000000000 (seq 3)


23:41:50.570| CBLDatabase: ForestDB: DB 0x107193440: added 01 --> 070540d85d800000000005408a6000000000000639282d392d2c2926373327282f2d29272f372726392f2d262735353329393133282e332b2d292d2b0004400fffffffffffff053ff000000000000005400800000000000000 (seq 3)


23:41:50.572| CBLDatabase: Read "fld-8E0533538F55468CADA9F386E5481A56" / 1-682ab546848e76095d34a3d07b5127f0 (seq 680) 

1: (680) 1-682ab546848e76095d34a3d07b5127f0   leaf



Thanks,

Brendan

Jens Alfke

unread,
Sep 18, 2015, 1:45:28 PM9/18/15
to mobile-c...@googlegroups.com

On Sep 17, 2015, at 10:46 PM, Brendan Duddridge <bren...@gmail.com> wrote:

Hi,

Does CBL re-generate all the views after you've encrypted or decrypted the database?

With SQLite, the view indexes are in the same file as the documents, so everything’s encrypted together.

With ForestDB, the indexes are separate files, and the re-keying process deletes them rather than encrypting them, so they’ll get re-built on demand. This was mostly to make the code simpler and the re-keying faster.

I find that after I encrypt or decrypt, the next time I open the database, it takes a while to open the database. Subsequent opens are quick.

It shouldn’t take longer to open the database, but the first query of each view afterwards will be slow. If this is turning into a performance problem for your app, file an issue and we can look into changing the code to re-encrypt the index files.

—Jens

Brendan Duddridge

unread,
Sep 18, 2015, 2:42:40 PM9/18/15
to Couchbase Mobile
Hi Jens,

It's not an issue for me really. It's not that long of a delay (at least not in my test cases currently). It was more of just wondering if that's how it worked so I knew the reason for it. Your explanation confirmed my suspicions. No further action required.

Thanks,

Brendan
Reply all
Reply to author
Forward
0 new messages