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

Bucket shadowing not propagating deletes #285

Closed
jnordberg opened this issue Mar 2, 2014 · 10 comments
Closed

Bucket shadowing not propagating deletes #285

jnordberg opened this issue Mar 2, 2014 · 10 comments

Comments

@jnordberg
Copy link
Contributor

When removing a document from the bucket that is being shadowed the sync bucket is not updated. New documents and updates works fine.

@jessliu
Copy link

jessliu commented Mar 6, 2014

@snej or @andreibaranouski do we have a test for this? Can we reproduce?

@jnordberg do you have any other information that you can share, such as how the document was removed, how the sync function was set up, etc.?

@jnordberg
Copy link
Contributor Author

The document was removed from the bucket by a remove call via coucbhaselib, changes never propagate. From what i can tell sync_gateway isn't even getting a message that something happened.

sync fn

function(doc, oldDoc) {

  if (doc._deleted) {
    requireUser(oldDoc.owner);
    return;
  }

  function isValidUsername(name) {
    return (typeof name == 'string' && /^[0-9a-z]+$/.test(name));
  }

  if (!isValidUsername(doc.owner)) {
    throw ({forbidden: "invalid document owner"});
  }

  if (!(Array.isArray(doc.members) && doc.members.every(isValidUsername))) {
    throw ({forbidden: "invalid document members"});
  }

  if (oldDoc) {
    // validate changes
    if (doc.owner != oldDoc.owner) {
      // only admins can change the owner of a document
      requireRole('admin');
    }

    // only doc.members and admins can modify the document
    if (!haveUser(oldDoc.owner) && !haveUser(oldDoc.members) && !haveRole('admin')) {
      throw ({forbidden: 'no access'});
    }
  } else {
    // validate new document
    // only allow users to create documents as themselves
    requireUser(doc.owner);
  }

  channel(doc.owner, doc.members);
}

@snej
Copy link
Contributor

snej commented Mar 7, 2014

Try turning on "CRUD" and "Shadow+" logging. You should get some logs regarding the deletion. Please post them here.

@jessliu
Copy link

jessliu commented Mar 26, 2014

@jnordberg is this issue still persisting after turning on CRUD and/or Shadow+? Also, can you try using the latest stable branch? There is a possible fix for this.

@jessliu jessliu added this to the G.A. milestone Mar 26, 2014
@snej snej added bug labels Mar 26, 2014
@jnordberg
Copy link
Contributor Author

We changed our setup so we didn't need the bucket shadowing, i'll see if i can reproduce just by keeping a shadow running on our new setup

@jnordberg
Copy link
Contributor Author

Same thing... If i delete a document via the sync gateway the document in the bucket gets deleted, if i do it the other way around and delete it from the shadow bucket it still appears in the gateway and the logs are silent.

Also i noticed now that turning it on for an existing bucket did not shadow all the existing document, just stuff that was created/updated after shadowing was turned on.

@jessliu
Copy link

jessliu commented Mar 27, 2014

I see, thank you. Instead of bucket shadowing what are you using instead?

@jnordberg
Copy link
Contributor Author

We are using the gateway as db for our backend as well, over the admin interface, never talking directly to the couchbase server

@snej
Copy link
Contributor

snej commented Mar 27, 2014

Our unit tests are infallible so there's no way this could be happening 😉 but I'll humor you and test this manually today using a real Couchbase Server bucket.

@snej snej closed this as completed in 9e71ab4 Apr 2, 2014
@snej
Copy link
Contributor

snej commented Apr 2, 2014

Fixed. For some reason Couchbase Server sends Tap deletion messages with a nonzero expiration field, even for non-expiring documents. The shadower code was ignoring all events with a nonzero expiration. Made it only ignore them when it's an insertion/update event, not deletion. Verified that deletion from a real Couchbase Server bucket is propagated to the gateway database.

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

No branches or pull requests

4 participants