Skip to content

Conversation

@jzhou77
Copy link
Contributor

@jzhou77 jzhou77 commented Jun 25, 2019

The size is the estimation of expected size of mutations, read conflict ranges, and write conflict ranges.

After the commit, the client may use Transaction::getSize() to get the exact commit size.

These APIs are available in version 620.

fdb_future_get_version is deprecated in version 620, i.e., 6.2 release. Instead, use fdb_future_get_int64 for the same behavior. All bindings will use fdb_future_get_int64 at version 620 and above.

This fixes #1682.

@jzhou77 jzhou77 force-pushed the db-option branch 3 times, most recently from 5b8e779 to f232158 Compare June 27, 2019 16:51
@AlvinMooreSr
Copy link
Contributor

@fdb-build test this please

@jzhou77 jzhou77 added this to the 6.2 milestone Jul 1, 2019
@jzhou77 jzhou77 force-pushed the db-option branch 2 times, most recently from 9b6f9a1 to 7f193da Compare July 2, 2019 21:45
@jzhou77 jzhou77 marked this pull request as ready for review July 2, 2019 21:52
@jzhou77 jzhou77 requested review from ajbeamon and alecgrieser July 3, 2019 02:21
jzhou77 added a commit to jzhou77/foundationdb that referenced this pull request Jul 5, 2019
@jzhou77
Copy link
Contributor Author

jzhou77 commented Jul 9, 2019

@fdb-build test this please

1 similar comment
@jzhou77
Copy link
Contributor Author

jzhou77 commented Jul 10, 2019

@fdb-build test this please

Both key and value has to be of type bytes.
@jzhou77
Copy link
Contributor Author

jzhou77 commented Jul 11, 2019

100k binding correctness tests passed.

Copy link
Contributor

@ajbeamon ajbeamon left a comment

Choose a reason for hiding this comment

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

I might be missing it, but it looks like the accounting for reads and atomic ops hasn't been added.

if(options.readYourWritesDisabled ) {
if (options.readYourWritesDisabled) {
approximateSize += key.expectedSize() + value.expectedSize() + sizeof(MutationRef) +
(addWriteConflict ? sizeof(KeyRangeRef) : 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are accounting for a conflict range here, I think we may also need to add 2 * key.expectedSize() + 1 for the keys in the range.

Also, do we need to add the conflict range cost here regardless of whether we are bypassing RYW? It looks like the conflict ranges aren't added until commit time (or possibly during usage of versionstamps), so we would probably also need to add a parameter to the conflict range adding functions to avoid updating the approximate size when called from those contexts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For read conflict ranges, add in ReadYourWritesTransaction::updateConflictMap or direct add for readYourWritesDisabled case.

For write conflict ranges, don't add their size in the commit time by adding a flag to ReadYourWritesTransaction::writeRangeToNativeTransaction. The idea is that, after commit, client code should call Transaction::getSize() to get transaction size.

throw key_outside_legal_range();

if( options.readYourWritesDisabled ) {
approximateSize += range.expectedSize() + sizeof(MutationRef) + (addWriteConflict ? sizeof(KeyRangeRef) : 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question about conflict range.

if (key.size() > (key.startsWith(systemKeys.begin) ? CLIENT_KNOBS->SYSTEM_KEY_SIZE_LIMIT : CLIENT_KNOBS->KEY_SIZE_LIMIT))
return key_too_large();

approximateSize += key.expectedSize() + sizeof(Watch);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking into this, it appears the cost of a watch in the commit request is one read conflict range. That means that you shouldn't add anything to size unless we are bypassing RYW, in which case you should add the cost of the conflict range.

jzhou77 and others added 5 commits July 11, 2019 14:00
Use fdb_future_get_int64 for language bindings and get rid of using Version
with getApproximateSize API.
Use fdb_future_get_int64 in all bindings.
Because different bindings may issue different limit for get_range calls, it is
impossible to return the same size value for getApproximateSize API. So we just
push a string to make sure binding test results are the same. Use another unit
test to make sure the sizes got back are monotonically increasing.
@jzhou77
Copy link
Contributor Author

jzhou77 commented Jul 15, 2019

Addressed all comments and 100k binding tests passed. @ajbeamon can you take one more look? Thanks!

Copy link
Contributor

@ajbeamon ajbeamon left a comment

Choose a reason for hiding this comment

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

FutureVersion type in Python can be removed as well.

Copy link
Contributor

@ajbeamon ajbeamon left a comment

Choose a reason for hiding this comment

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

We should also add some release notes for this. I think we'll probably need at least 2, one to describe the new feature and another to note that fdb_future_get_version has been renamed.

@jzhou77
Copy link
Contributor Author

jzhou77 commented Jul 17, 2019

Fixed all review comments and passed 100k binding tests.


int64_t version;
checkError(fdb_future_get_version(f, &version), "get version", rs);
checkError(fdb_future_get_int64(f, &version), "get version", rs);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same API version problem here.

@ajbeamon ajbeamon merged commit bc5c65e into apple:master Jul 19, 2019
jzhou77 added a commit to jzhou77/foundationdb that referenced this pull request Mar 31, 2020
This was missed from original PR apple#1756, where only C API was documented.
jzhou77 added a commit to jzhou77/foundationdb that referenced this pull request Mar 31, 2020
This was missed from original PR apple#1756, where only C API was documented.
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.

Add methods to transactions to get commit size

5 participants