Skip to content
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

update method issue #50

Closed
lucianboboc opened this issue Dec 27, 2016 · 6 comments
Closed

update method issue #50

lucianboboc opened this issue Dec 27, 2016 · 6 comments

Comments

@lucianboboc
Copy link

lucianboboc commented Dec 27, 2016

I have an issue with the db.update method, it is never called if it is inside another db closure.
If i retrieve an object from the db with an id, update it and call db.update the update's callback method is never called.
Also, my mac freezed and when i took a look at the swapped memory, it was a few dozens gb, check the attached image.
img_9888

I have created a gist for this: https://gist.github.com/lucianboboc/24a95fbc7234dbada8b80b1df23ffe2a

@lucianboboc lucianboboc changed the title update issue update method issue Dec 27, 2016
@shmuelk
Copy link
Collaborator

shmuelk commented Dec 28, 2016

@lucianboboc I am unable to recreate your failure.

This is what I tried:

1. Created a fresh directory.
2. Created a Package.swift file that contained:
 import PackageDescription 

 let package = Package(
 name: "CouchDB_50",
 dependencies: [
     .Package(url: "https://github.com/IBM-Swift/Kitura-CouchDB.git", majorVersion: 1, minor: 4),
 ])
3. Created a file main.swift and copied your program from the ghist.
4. Added a few imports that were missing (Foundation, CouchDB, and SwiftyJSON).
5. Ran `swift build` to compile the code
6. Used CouchDB's Web UI to create a database called test
7. Ran `.build/debug/CouchDB_50`

I then get the following output:

update callback
2-4d46b416f975fed36e83d97da3789180

I will also point out that I tried running .build/debug/CouchDB_50 again after having deleting the test database. The program ends immediately with no output. Again as expected.

@lucianboboc
Copy link
Author

Hi @shmuelk, Thank you for your message.
I'm using the Apache CouchDB 2.0 app for macOS and it runs in 'Admin Party' mode.
Indeed, the db object is updated and revision is increased, the issue is not about that, it is about the callback that's never received for the call to the update method:

database.update(id, rev: rev, document: newDocument) { rev, doc, error in
     print("update callback")
}

Have you tried to run in Xcode?
I also tried to run in terminal using ./.build/debug/testApp and i have the same problem, it remains 'waiting' and doesn't end.
I checked again in activity monitor and swap was 40gb...

@shmuelk
Copy link
Collaborator

shmuelk commented Dec 28, 2016

What version of Kitura-CouchDB are you using?

@lucianboboc
Copy link
Author

I'm using package 1.4

@shmuelk
Copy link
Collaborator

shmuelk commented Dec 28, 2016

I ran swift package generate-xcodeproj from the command, opened the generated XCode project using XCode 8.2.1, built the project and ran the project. I got the following output:

update callback
2-4d46b416f975fed36e83d97da3789180
Program ended with exit code: 0

Again your program seems to work for me.

Can you try closing the Apache CouchDB 2.0 app for macOS, when you run the test?

@lucianboboc
Copy link
Author

@shmuelk that was it, seems if i have the couchDB mac app open the update method will never be called and program doesn't end.
Thank you!

@shmuelk shmuelk closed this as completed Dec 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants