Skip to content

Implement a custom pouch purge solution #5048

Closed

Description

@garethbowen

Our users have a lot of documents on their phones. This is causing reduced with query performance, and eventually phones will run out of space altogether.

To solve this allow projects to provide configuration which defines when a document can be deleted off the phone. The document must not be deleted from the server couchdb so analytics and administrators can still access all documents. To achieve this run a service on the phone that purges a doc and modify the db-sync filter function so purged docs aren't replicated to the server.

Based on some performance profiling we decided to implement purge using the pouchdb remove function. However it may be that removed docs no longer have enough information to be filtered out. If that's the case, implement purge by minifying the doc, eg: { _id: doc._id, _rev: doc._rev, _deleted: true, purged: true }.

Activity

  1. self-assigned this
    on Dec 4, 2018
  2. SCdF commented on Dec 5, 2018

    @SCdF
    Contributor

    Status:

  3. garethbowen commented on Jan 10, 2019

    @garethbowen
    ContributorAuthor

    Backported to 3.3.x

  4. garethbowen commented on Jan 10, 2019

    @garethbowen
    ContributorAuthor

    @newtewt @ngaruko I've just added this feature to 3.3.0. As it destroys data it requires significant testing to ensure it works as expected.

  5. removed their assignment
    on Jan 11, 2019
  6. 6 remaining items

  7. SCdF commented on Jan 30, 2019

    @SCdF
    Contributor

    @newtewt this is very strange. Let me take a look

  8. SCdF commented on Jan 30, 2019

    @SCdF
    Contributor

    Found the problem, I nicked a hash function from elsewhere and didn't convert it out of being prototyped against a string correctly. This PR fixes it: #5317

  9. SCdF commented on Jan 31, 2019

    @SCdF
    Contributor

    I have merged this fix and backported it to 3.3.x and 3.4.x, but I haven't done any releases on these branches.

    @newtewt let me know if you need me to perform any more next steps here.

  10. removed their assignment
    on Jan 31, 2019
  11. newtewt commented on Jan 31, 2019

    @newtewt
    Contributor

    @SCdF may have found another issue. I am changing the date of medic-last-purge-date and then refreshing the app. I'm not seeing the purge rerun. The console displays Initiating purge inbox.js:3 Local DB may have unreplicated records, skipping but my sync is up to date. Looking in local storage I don't see an entry for medic-last-replicated-seq and when calling window.localStorage.getItem("medic-last-replicated-seq") it returns null.

  12. SCdF commented on Feb 1, 2019

    @SCdF
    Contributor

    NB: this works in master, but is not working in 3.3.x. I'm guessing the backport is incompatible with some kind of flow here, I'm looking into it.

    I'll also check the 3.4.x branch once I figure it out as well.

  13. SCdF commented on Feb 1, 2019

    @SCdF
    Contributor

    I have fixed this for 3.3.x (you need to wait for the build to complete).

    The issue came about because the logic on how we replicate is different in 3.3.x compared to the version purging was originally build for and we didn't take that into account when backporting.

  14. SCdF commented on Feb 1, 2019

    @SCdF
    Contributor

    3.4.x seems to be working fine

  15. newtewt commented on Feb 6, 2019

    @newtewt
    Contributor

    Purging is working as expected. Docs are removed only from the offline user.

  16. BananaAcid commented on May 3, 2020

    @BananaAcid

    So is this rolled out/documented and possible to use?

  17. SCdF commented on May 6, 2020

    @SCdF
    Contributor

    Answered-ish here: apache/pouchdb#802 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions