-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
IndexedDB size in Chrome keeps increasing whenever doc is updated #7100
Comments
How about after |
Just noticed you have revs_limit: 1, compaction shouldnt really be needed, however how are you measuring the disk size here? if you are measuring the leveldb files directly then chrome may be doing some bookeeping that we dont know about, I would confirm in the inspector that there is no more data stored than you expect, with the code you have shown I wouldnt expect a growing database either. If there isnt any extra data stored by pouchdb then I think you may have to start looking at chromes implementation |
I read PouchDB uses indexedDB by default. And I'm seeing indexedDB size increasing actually in Chrome (You can see it by clicking "Clear storage" option). 1. This is really confusing. Two of your developers say don't use auto_compaction here. You can see them https://github.com/pouchdb/pouchdb/issues/4372. They discuss NOT using auto_compaction. 2. One thing you might want to know: When the size reaches near 4MB, the size automatically reduces to minimum, maybe equal to actual size. But this does actually increase with each update and it's really frustrating! |
db.compact() makes no difference! |
You shouldnt need |
Please read your own comment here: #4372 You say "As a workaround it looks like everything is fine with revs_limits: 1 only, if revs_limit is 1 then auto_compaction isnt needed anyway" there. Also, same is mentioned here in comments https://stackoverflow.com/questions/37182802/pouchdb-growing-with-revisions-even-when-revs-limit-1 |
By developer I mean guys who reply the issues. |
Further can you please tell me how to look that unexpected data that might be there? |
In chrome bring up the console and there is an IndexedDB inspector, in my chrome its under the "Application" tab but that seems new, it may be "Storage" in other versions, I made https://petite-space.glitch.me/ and confirmed that I cant see PouchDB storing any data that isnt expected |
I'm not in my office now but I'll try and let you know tomorrow. But one thing, why did you say in your 2nd comment that auto_compaction is needed? |
I hadnt noticed that you were using revs_limit:1 |
So compaction not needed when revs_limit:1? |
Nope |
Thanks. |
Cheers, gonna close this out since I am pretty convinced it isnt a pouch issue after inspect, but feel free to ask questions in here and can reopen if we find something that pouchdb can do about it |
I opened the link you gave and did reload it 5-6 times and clicked Run Code every time: Here's what I saw in storage (approx.): 6 kb, 9kb, 12kb, 16kb etc. When I inspected the IndexedDB, I saw this (I don't know what else to see, but this seemed relevant to me: There are two tabs having one child each, so I clicked on 1+1+1+1 = 4 tabs and these were the results:
|
If you need, I can provide you a screenshot. |
Waiting for your reply. It may not be issue with Chrome. |
Having 1 row in document store and by seq store is expected |
So the issue is definitely with PouchDB. It somehow doesn't compact tha data. It waits for 4-5MB then does it. When will you fix it? |
To be clear, I nor anyone else here works for you, I have tried to patiently help you but that has a limit.
The 2 documents you mentioned (I see the same) are entirely expected and indicate the issue is not with PouchDB. Nor does pouchdb have any code that waits for the database to be 4mb before compacting. |
Okay. So what may be wrong. I can reproduce same issue in Chrome 60+ and Chromium browser. Is there any way to fix it? |
Seems a lot like https://github.com/google/leveldb/blob/master/doc/impl.md and is expected behaviour |
This seems complex to understand for me. Now main thing is: I believe more size makes the pouchDB .find method slow. Is it true that if size is more fetching docs would be slow? If it isn't I wont' be having any issue with it as it automatically does reset. |
The link clearly explains why leveldb databases will grow until 4mb which will not effect find performance. Please do not post issues unless you really willing to attempt to understand the issue at hand especially when being guided, it is extremely disrespectful of peoples time |
Ok. Could you please tell one more thing: We do new PouchDB('name").destroy() to remove DB at login and log out. Now, in Safari browser, we see same DB created TWICE! Is there any chance that using new PouchDB everytime (although name is same) to delete or fetch data is messing things up? |
No there isnt |
Okay. Last query: Our website becomes too slow when we save data for around 100 devices (the data is similar to the JSON object that I have added in details). Now you may have noticed that I have stored long strings in the key's value for some of the keys. And even nested JSON strings as well. So I assume that more is the size of a doc, more will be time in fetching and updating it. Is it really like this? Further, we update each document using a for loop. So that we can first fetch the docId and _rev to update them. This is another major reason for our site's slow performance. Isn't there any other way to update all docs? I know about bulk update but that too requires _rev of original docs. |
Wait. I noticed this here: https://petite-space.glitch.me/ And our website stores around 500 kb data. So db.compact() might be increasing a lot of data! |
Please reply. It's a genuine question. |
For the benefit of anyone else arriving here from Google: it seems Chromes IDB implementation will keep increasing in size as you call objectStore.put until it reaches about 4MB, at which time it does a memory dump right back to where it started. I don't know why it does this, but it was miserable to debug, to confirm that my code was not leaking memory somehow |
Chrome related issue https://bugs.chromium.org/p/chromium/issues/detail?id=795735 |
Issue
I create a doc (code is below) on first page reload and then update the doc every time the page is reloaded or manually updated. On fresh page load, the db size is 6-10 kb. But it increases by 3-4 kb on on each update.
I read 2 related issues (that suggested updating .js file and I'm using 6.4.3 version now) and tried exactly what they said. But it's not working at all.
Here's what I'm doing:
Even testDb.viewCleanup() doesn't work.
Info
Reproduce
Just update the created doc with some more info and you'll see the DB size is increasing.
The text was updated successfully, but these errors were encountered: