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

Range-supporting DB#delete method (hard deletes) #208

Merged
merged 7 commits into from
Jul 14, 2017

Conversation

eevans
Copy link
Contributor

@eevans eevans commented Jul 11, 2017

@coveralls
Copy link

coveralls commented Jul 11, 2017

Coverage Status

Coverage increased (+0.2%) to 85.629% when pulling b4c6ffc on eevans:redesign into a29552f on wikimedia:redesign.

Copy link
Contributor

@Pchelolo Pchelolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several nits and questions inlined

lib/db.js Outdated
const queryOptions = { consistency: req.consistency, prepare: true };
const queryInfo = dbu.buildDeleteQuery(req);
return this.client.execute(queryInfo.cql, queryInfo.params, queryOptions).thenReturn({
status: 201
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the RFC for DELETE requests:

A successful response SHOULD be 200 (OK) if the response includes an entity describing the status, 202 (Accepted) if the action has not yet been enacted, or 204 (No Content) if the action has been enacted but the response does not include an entity.

So in our case it should be 204

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this was copy-pasta; I meant to circle back around and find the right status.

lib/dbutils.js Outdated
const schema = req.schema;
const query = req.query;
const attributes = query.attributes || {};
if (req.columnFamily !== 'meta') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Em, what? We shouldn't allow issuing deletes to meta table, it's our internal implementation detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrmm, we do use this interface to (for example), write to meta. See lib/db.js#L657, and the similar handling in lib/dbutils.js#L656. I can't think of any reason that we'd need to do deletes on meta, but I wasn't sure there was reason to exclude it either.

Do you think we should raise an exception instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think deleting from meta is dangerous enough to raise an exception. If we delete from meta we effectively make the key space completely unusable.

block_size: 256
}
]
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to explicitly overwrite defaults?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this was just more copy-pasta. This whole test file will be deleted though once tests are in place in wikimedia/restbase-mod-table-spec (i was just using this to sort out the initial implementation).

});
});
});

after(function() {
return db.dropTable('restbase.cassandra.test.local', 'simple-table');
return P.map(['simple-table', 'even-simpler-table'], (i) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general for one-liners we don't use brackets for the param or curly brackets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha

@@ -70,4 +97,51 @@ describe('Delete', function() {
}
});
});

it('puts the lotion on its skin', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)


it('puts the lotion on its skin', () => {
return P.map(Array.from(new Array(20), (x, i) => i), (rev) => {
return db.put('restbase.cassandra.test.local', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem regarding brackets

@coveralls
Copy link

coveralls commented Jul 12, 2017

Coverage Status

Coverage decreased (-0.08%) to 85.325% when pulling 02ecc0c on eevans:redesign into a29552f on wikimedia:redesign.

@coveralls
Copy link

coveralls commented Jul 12, 2017

Coverage Status

Coverage decreased (-0.08%) to 85.325% when pulling 3242b75 on eevans:redesign into a29552f on wikimedia:redesign.

@coveralls
Copy link

coveralls commented Jul 12, 2017

Coverage Status

Coverage decreased (-1.7%) to 83.669% when pulling bb36781 on eevans:redesign into a29552f on wikimedia:redesign.

@eevans eevans changed the title WIP: a range-supporting DB#delete method (hard deletes) Range-supporting DB#delete method (hard deletes) Jul 12, 2017
@coveralls
Copy link

coveralls commented Jul 12, 2017

Coverage Status

Coverage decreased (-1.8%) to 83.57% when pulling 0b2edbc on eevans:redesign into a29552f on wikimedia:redesign.

Copy link
Contributor

@d00rman d00rman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits in-lined, otherwise 👍

index.js Outdated
// XXX: Use the path to determine the primary key?
return this.store.delete(domain, req.body)
.thenReturn({
// created
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: // deleted ?

body: {
type: 'delete_error',
title: 'Internal error in Cassandra table storage backend',
stack: e.stack,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the stack here explicitly when the error below ought to contain it as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a Good Question. The short and unsatisfying answer is that it is that way to be consistent with the other request types; I don't know why they are that way. I wonder if it doesn't end up output as [object] or something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see. Let's leave this be for now then and address all of the cases at once.

lib/dbutils.js Outdated
* CQL building for DELETE queries
* @param {InternalRequest} req
* @param {object} options map
* @return {object} queryInfo object with cql and params attributes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter two do not seem to be function arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrmm, not sure what you mean. The options map object argument is copy-pasta (I've removed that), is that what you mean?

@coveralls
Copy link

coveralls commented Jul 14, 2017

Coverage Status

Coverage decreased (-1.8%) to 83.57% when pulling cf48068 on eevans:redesign into a29552f on wikimedia:redesign.

@d00rman d00rman merged commit 50623da into wikimedia:redesign Jul 14, 2017
Pchelolo pushed a commit that referenced this pull request Jul 31, 2017
* Range-supporting DB#delete (hard deletes)

Bug: https://phabricator.wikimedia.org/T169938

* Expose delete operation

Bug: https://phabricator.wikimedia.org/T169938

* Incorporate review feedback

Bug: https://phabricator.wikimedia.org/T169938

* Return the correct HTTP status code

Bug: https://phabricator.wikimedia.org/T169938

* Remove delete test (replaced w/ a functional test in rb-m-t-spec)

Bug: https://phabricator.wikimedia.org/T169938

* Disallow deleting from `meta` columnfamily

Bug: https://phabricator.wikimedia.org/T169938

* Clean up some nits; Address review feedback

https://www.mediawiki.org/wiki/RESTBase/StorageDesign
@eevans eevans deleted the redesign branch January 8, 2018 21:47
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

Successfully merging this pull request may close these issues.

4 participants