Question about document/attachment size

194 views
Skip to first unread message

Ryan Payne

unread,
Nov 28, 2013, 2:52:38 PM11/28/13
to mobile-c...@googlegroups.com
I've found some info in the docs saying Document limit is 10MB and attachment is 20MB. Just want to confirm that there is no limit on the amount of attachments on a document. Hypothetically, let's say I have a 20kb document with 27 1MB attachments. This is acceptable yes?

Jens Alfke

unread,
Nov 28, 2013, 3:02:59 PM11/28/13
to mobile-c...@googlegroups.com

On Nov 28, 2013, at 11:52 AM, Ryan Payne <ryanpayn...@gmail.com> wrote:

I've found some info in the docs saying Document limit is 10MB and attachment is 20MB. Just want to confirm that there is no limit on the amount of attachments on a document. Hypothetically, let's say I have a 20kb document with 27 1MB attachments. This is acceptable yes?

Yes. On the server each attachment is stored as a separate document in the bucket.

—Jens

Ryan Payne

unread,
Nov 28, 2013, 5:36:44 PM11/28/13
to mobile-c...@googlegroups.com
Ok I've done it this way and now I am having issues with the app syncing.

First here's an abbreviated example of the document

{
"Data": {
   "Outlets": [
   {
      "Base64Logo": null,
      "Building": "William G. Davis Computer Research Centre",
      "DatesClosed": [
         "2013-12-18T00:00:00"
      ]
      etc......
   },
   etc......
]
},
"_attachments": {
    "BA.gif": {
      "content_type": "image/gif",
      "digest": "sha1-VipoI8BiZUffggTtNW20B3FXSCc=",
      "length": 3612,
      "revpos": 2,
      "stub": true
    },
    "browsers.gif": {
      "content_type": "image/gif",
      "digest": "sha1-RBEOHeqsRAXLmPUZqcZ4FmbN0/s=",
      "length": 2262,
      "revpos": 2,
      "stub": true
    },
    etc......
}
"_sync": {
    "rev": "2-6382d15b5661cccd94132c097657c880",
    "sequence": 6,
    "history": {
      "revs": [
        "1-34d94ce7897bbbcb5100f7696862062e",
        "2-6382d15b5661cccd94132c097657c880"
      ],
      "parents": [
        -1,
        0
      ],
      "bodies": [
        "",
        ""
      ],
      "channels": [
        null,
        null
      ]
    }
  }

I'm inserting this stuff through the sync gateway REST API the same way I have been doing. I've had no issues at all until now adding attachments

I notice when I make the PUT, on the sync gateway terminal it goes into an endless stream of:

go-couchbase: TAP connection lost; reconnecting to bucket "iwaterloo" in 1s

This continues every second infinitely until I reboot the entire server. If I shut down sync gateway and restart it just immediately goes back into that. I need to shut the whole thing down to make it stop.

Second, 

When I boot the app and try to sync, the gateway appears to be working fine and retrieving the docs as usual, but in the application output I'm getting the below for every document:

2013-11-28 17:15:06.388 iWaterloo[11591:80b] WARNING*** : Exception raised during -inTransaction: -[NSNull count]: unrecognized selector sent to instance 0x5376068
2013-11-28 17:15:06.388 iWaterloo[11591:80b] WARNING*** : CBL_Puller[http://....removed...] failed to write {diets #1-ce194927634a241f4107e6941f040c07}: status=594

So basically everything seems to be working fine, but the documents won't write locally on the simulator/device. Everything was working perfectly prior to using attachments.

I deleted the bucket completely and started fresh but got the same issue again.

I'm using the Xamarin version so perhaps the issue is with the bindings. Not sure.

Thanks

Jens Alfke

unread,
Nov 28, 2013, 10:28:13 PM11/28/13
to mobile-c...@googlegroups.com
Please file a bug report. Actually two, the first against the gateway and the second against CBL. You’re getting some internal errors that should not be happening. Thanks!

About the document: How many attachments are there, and what sizes?

About the Couchbase Lite exception: if you could catch a backtrace of the exception that would be great. Set an all-exceptions breakpoint in your app project (use the + button at the bottom of the breakpoints navigator) and when it’s hit, use the “bt” debugger command to log a backtrace.

Oh, and what versions of the respective codebases?

—Jens

Ryan Payne

unread,
Nov 29, 2013, 3:00:03 PM11/29/13
to mobile-c...@googlegroups.com
I've filed a bug report for sync gateway.

I haven't done anything regarding the CBL exception yet because I don't know how I can get the backtrace/breakpoint. I'm using Xamarin Studio not XCode and I can't figure out how to turn all exceptions on, both by looking and searching. Any ideas or maybe we can forward that question to the Xamarin team?

For codebases, I'm using whatever the CBL is in the Xamarin component store, which is 1.479.1, and the assembly is Couchbase - 1.0.5021.33491

For Sync Gateway, I couldn't find anything that said what version other than 1.0 Beta. I cloned the repository and built it myself on Nov 6. If you tell me where to find the version iteration I will take a look and report back

Jens Alfke

unread,
Nov 29, 2013, 7:33:59 PM11/29/13
to mobile-c...@googlegroups.com

On Nov 29, 2013, at 12:00 PM, Ryan Payne <ryanpayn...@gmail.com> wrote:

For Sync Gateway, I couldn't find anything that said what version other than 1.0 Beta. I cloned the repository and built it myself on Nov 6. If you tell me where to find the version iteration I will take a look and report back

‘git log -1’ (that’s a one, not an L) will show you the ID of the latest commit.

—Jens

Ryan Payne

unread,
Dec 2, 2013, 11:56:52 AM12/2/13
to mobile-c...@googlegroups.com
Here is the commit ID for Sync Gateway 2f709d9193ed6352872ed951c9bee41aa81d1458

Zachary Gramana

unread,
Dec 9, 2013, 9:11:07 PM12/9/13
to mobile-c...@googlegroups.com
Ryan,

Please update to the latest version of the component, which is https://components.xamarin.com/view/couchbase-lite?version=1.479.3, and see if the issue persists. There were some improvements in the bindings that were identified by our new static registrar.

When the exceptions are unhandled, in most cases, you are provided with the native stacktrace in the managed exception that the Mono runtime gives you. Either way, you can retrieve the backtrace from the iOS logs available under Xcode > Organizer > Devices > [Your Test Device] > Devices Logs > Process > [Your App's Name]. You can get ASL output directly in Xamarin Studio or Visual Studio via the "iOS Device Log" pad/panel.

If you want to debug your Xamarin app using LLDB to get a backtrace, then do the following:

2) Run `make` inside that folder.
3) Run `./ios-deploy -d -b path/to/bin/iPhone/Debug/MyFoo.app`

This will install your app and start it will lldb attached.

From the lldb prompt:

Add your breakpoint: 

1)  breakpoint set --file CBLDatabase+Internal.m --line 560
2) target stop-hook add
3)  bt
4) DONE
5) c

When that breakpoint hits, it will dump the backtrace to the console, where you can copy and paste it.

Cheers,
Zack

Zachary Gramana

unread,
Dec 9, 2013, 9:17:23 PM12/9/13
to mobile-c...@googlegroups.com
Quick note:

Change
  5) c
to
  3) run

Ryan Payne

unread,
Dec 10, 2013, 2:44:38 PM12/10/13
to mobile-c...@googlegroups.com
Updating the component did not make a difference

The iOS device logs did not tell me anything that wasn't already being output in the debugger. To clarify, these issues are not causing a crash so there is no crash backtrace. They are just being trapped in try/catch and suppressed.

I don't know what you mean change 5)c to 3) run....is that supposed to be 5) c to 5) run? Or change both 5 and 3? I tried just changing 5 to run and as soon as I run, the app launches and immediately exits with "error: failed to get the task for process 1618"

I just noticed my Monotouch license expired literally 2 days ago, so could this be preventing it from attaching to the process?

Zack Gramana

unread,
Dec 10, 2013, 3:07:37 PM12/10/13
to mobile-c...@googlegroups.com
Yep, copy 'n paste error. Should be 5) c to 5) run. If you’re using my latest commit/dropbox binary, you’ll want to be sure to add -n when you invoke ios-deploy.

Not sure about that license issue or the error, though it’s quite possible. If were just a locked phone, the error message would be “Locked."

Ryan Payne

unread,
Dec 10, 2013, 3:14:10 PM12/10/13
to mobile-c...@googlegroups.com
Still getting the "failed to get the task for process" error. I guess I will have to try once I renew the license to rule that out.

Zack Gramana

unread,
Dec 10, 2013, 3:15:38 PM12/10/13
to mobile-c...@googlegroups.com

On Dec 10, 2013, at 11:44 AM, Ryan Payne <ryanpayn...@gmail.com> wrote:

app launches and immediately exits with "error: failed to get the task for process 1618"

You may also want to provide the -i {device-id} parameter, in case you have multiple iOS devices plugged-in.

You can find the device id with the command:

   system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'

Ryan Payne

unread,
Jan 20, 2014, 5:14:45 PM1/20/14
to mobile-c...@googlegroups.com
I think I've figured out what the issue is here.....

I have a generic base document class that I use for inserting, and it has an _attachments property. Not every document has attachments, so it gets inserted with "_attachments": null

I flushed my bucket and inserted all the documents again fresh, and now not even one document will sync. I conclude the reason only some were not before is because there were existing documents in the bucket from before that did not have the _attachments property.

How do you suggest I handle this? Will I be forced to omit the _attachments property if there are none, or is there a default value I can use like an empty string?

Jens Alfke

unread,
Jan 20, 2014, 5:21:05 PM1/20/14
to mobile-c...@googlegroups.com

On Jan 20, 2014, at 2:14 PM, Ryan Payne <ryanpayn...@gmail.com> wrote:

I have a generic base document class that I use for inserting, and it has an _attachments property. Not every document has attachments, so it gets inserted with "_attachments": null

null is not a valid value for _attachments — it needs to be a dictionary. If you don't have any attachments, use an empty dictionary, "{}".

With the CBL  beta 2 API you shouldn't need to manipulate _attachments yourself … it's cleaner to let CBLRevision and CBLModel do it for you.

—Jens
Reply all
Reply to author
Forward
0 new messages