Very long "_sync" history in my documents created in couchbase lite

Hi

I’m trying to create documents in couchbase lite (android) and sync them to my couchbase server.
When I open the synced document in the cb server console, there is a huge attachment which is increasing with every update of this document.
It looks like this:

"_sync": {
"rev": "3-b0f9687894fa52544984b06a3c8849e99dfef67f",
"sequence": 285,
"recent_sequences": [
  280,
  281,
  285
],
"history": {
  "revs": [
    "1-797038d0ea0ada87cfe6d5cbc4f07207c1853ebf",
    "2-0a17cd1b7ff07dd692b58a3e265b95de02215335",
    "3-b0f9687894fa52544984b06a3c8849e99dfef67f"
  ],
  "parents": [
    -1,
    0,
    1
  ],
  "channels": [
    [
      "user_channel::daniel"
    ],
    [
      "user_channel::daniel"
    ],
    [
      "user_channel::daniel"
    ]
  ]
},
"channels": {
  "user_channel::daniel": null
},
"access": {
  "daniel": {
    "user_channel::daniel": 280
  }
},
"cas": "",
"value_crc32c": "",
"time_saved": "2019-02-09T11:07:08.7798052+01:00"

},

Why is this added to my document? How can I remove this?

What you’re seeing is the meta data that allows sync to work. Couchbase Mobile uses something called multi-version concurrency control. Roughly this means it retains a history of revisions. (It does not retain the entire document, just hashes and some other information.) This is so it can tell when two modified documents have the same ancestor. In other words, so it can do conflict detection. You can read an excellent description of what’s going on here.

This data should not be that large. When you say “huge attachment”, how much data are you talking about?

You can tune the number of revisions it tracks. This has the potential downside of missing conflicting mutations. You can read more about managing database size in general here.