Skip to content

Expose APPEND_IF_FITS to clients #22

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

Merged
merged 3 commits into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bindings/bindingtester/tests/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# limitations under the License.
#

import ctypes
import random
import struct

Expand Down Expand Up @@ -169,7 +168,7 @@ def generate(self, args, thread_number):
op_choices += resets

idempotent_atomic_ops = [u'BIT_AND', u'BIT_OR', u'MAX', u'MIN', u'BYTE_MIN', u'BYTE_MAX']
atomic_ops = idempotent_atomic_ops + [u'ADD', u'BIT_XOR']
atomic_ops = idempotent_atomic_ops + [u'ADD', u'BIT_XOR', u'APPEND_IF_FITS']

if args.concurrency > 1:
self.max_keys = random.randint(100, 1000)
Expand Down
1 change: 1 addition & 0 deletions bindings/flow/tester/Tester.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,7 @@ void populateAtomicOpMap() {
optionInfo["BIT_OR"] = FDBMutationType::FDB_MUTATION_TYPE_BIT_OR;
optionInfo["XOR"] = FDBMutationType::FDB_MUTATION_TYPE_XOR;
optionInfo["BIT_XOR"] = FDBMutationType::FDB_MUTATION_TYPE_BIT_XOR;
optionInfo["APPEND_IF_FITS"] = FDBMutationType::FDB_MUTATION_TYPE_APPEND_IF_FITS;
optionInfo["MAX"] = FDBMutationType::FDB_MUTATION_TYPE_MAX;
optionInfo["MIN"] = FDBMutationType::FDB_MUTATION_TYPE_MIN;
optionInfo["SET_VERSIONSTAMPED_KEY"] = FDBMutationType::FDB_MUTATION_TYPE_SET_VERSIONSTAMPED_KEY;
Expand Down
4 changes: 2 additions & 2 deletions fdbclient/ReadYourWrites.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ void ReadYourWritesTransaction::atomicOp( const KeyRef& key, const ValueRef& ope
if(key >= getMaxWriteKey())
throw key_outside_legal_range();

if(!isValidMutationType(operationType) || !isAtomicOp((MutationRef::Type) operationType) || operationType == MutationRef::AppendIfFits)
if(!isValidMutationType(operationType) || !isAtomicOp((MutationRef::Type) operationType))
throw invalid_mutation_type();

if(key.size() > (key.startsWith(systemKeys.begin) ? CLIENT_KNOBS->SYSTEM_KEY_SIZE_LIMIT : CLIENT_KNOBS->KEY_SIZE_LIMIT))
Expand Down Expand Up @@ -1898,4 +1898,4 @@ void ReadYourWritesTransaction::debugLogRetries(Optional<Error> error) {
transactionDebugInfo->lastRetryLogTime = now();
}
}
}
}
3 changes: 3 additions & 0 deletions fdbclient/vexillographer/fdb.options
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ description is not currently required but encouraged.
<Option name="bit_xor" code="8"
paramType="Bytes" paramDescription="value with which to perform bitwise xor"
description="Performs a bitwise ``xor`` operation. If the existing value in the database is not present or shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``."/>
<Option name="append_if_fits" code="9"
paramType="Bytes" paramDescription="value to append to the database value"
description="Appends ``param`` to the end of the existing value already in the database at the given key (or creates the key and sets the value to ``param`` if the key is empty). This will only append the value if the final concatenated value size is less than or equal to the maximum value size (i.e., if it fits). WARNING: No error is surfaced back to the user if the final value is too large because the mutation will not be applied until after the transaction has been committed. Therefore, it is only safe to use this mutation type if one can guarantee that one will keep the total value size under the maximum size."/>
<Option name="max" code="12"
paramType="Bytes" paramDescription="value to check against database value"
description="Performs a little-endian comparison of byte strings. If the existing value in the database is not present or shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. The larger of the two values is then stored in the database."/>
Expand Down
2 changes: 1 addition & 1 deletion fdbserver/workloads/FuzzApiCorrectness.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ struct FuzzApiCorrectnessWorkload : TestWorkload {
std::make_pair( error_code_key_too_large, ExceptionContract::requiredIf(key.size() > (key.startsWith(systemKeys.begin) ? CLIENT_KNOBS->SYSTEM_KEY_SIZE_LIMIT : CLIENT_KNOBS->KEY_SIZE_LIMIT)) ),
std::make_pair( error_code_value_too_large, ExceptionContract::requiredIf(value.size() > CLIENT_KNOBS->VALUE_SIZE_LIMIT) ),
std::make_pair( error_code_invalid_mutation_type, ExceptionContract::requiredIf(
!isValidMutationType(op) || !isAtomicOp((MutationRef::Type) op) || op == MutationRef::AppendIfFits ) ),
!isValidMutationType(op) || !isAtomicOp((MutationRef::Type) op)) ),
std::make_pair( error_code_key_outside_legal_range, ExceptionContract::requiredIf(
(key >= (workload->useSystemKeys ? systemKeys.end : normalKeys.end))) ),
std::make_pair( error_code_client_invalid_operation, ExceptionContract::requiredIf(
Expand Down
60 changes: 30 additions & 30 deletions fdbserver/workloads/RandomSelector.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct RandomSelectorWorkload : TestWorkload {

try {
for(i = 0; i < g_random->randomInt(self->minOperationsPerTransaction,self->maxOperationsPerTransaction+1); i++) {
j = g_random->randomInt(0,15);
j = g_random->randomInt(0,16);
if( j < 3 ) {
myKeyA = format( "%010d", g_random->randomInt( 0, self->maxKeySpace+1 ) );
myValue = format("%d", g_random->randomInt( 0, 10000000 ) );
Expand Down Expand Up @@ -237,30 +237,30 @@ struct RandomSelectorWorkload : TestWorkload {
}
}
}
//else if( j < 8 ) {
// myKeyA = format( "%010d", g_random->randomInt( 0, self->maxKeySpace+1 ) );
// myRandomIDKey = format( "%010d", g_random->randomInt(0, 1000000000) );
// myValue = format("%d", g_random->randomInt( 0, 10000000 ) );
// //TraceEvent("RYOWappendIfFits").detail("Key",myKeyA).detail("Value", myValue);
// trRYOW.atomicOp(StringRef(clientID + "b/" + myKeyA), myValue, MutationRef::AppendIfFits);
//
// loop {
// try {
// tr.set(StringRef(clientID + "z/" + myRandomIDKey), StringRef());
// tr.atomicOp(StringRef(clientID + "d/" + myKeyA), myValue, MutationRef::AppendIfFits);
// Void _ = wait( tr.commit() );
// break;
// } catch (Error& e) {
// error = e;
// Void _ = wait( tr.onError(e) );
// if(error.code() == error_code_commit_unknown_result) {
// Optional<Value> thing = wait(tr.get(StringRef(clientID+"z/"+myRandomIDKey)));
// if (thing.present()) break;
// }
// }
// }
//}
else if( j < 8 ) {
myKeyA = format( "%010d", g_random->randomInt( 0, self->maxKeySpace+1 ) );
myRandomIDKey = format( "%010d", g_random->randomInt(0, 1000000000) );
myValue = format("%d", g_random->randomInt( 0, 10000000 ) );
//TraceEvent("RYOWappendIfFits").detail("Key",myKeyA).detail("Value", myValue);
trRYOW.atomicOp(StringRef(clientID + "b/" + myKeyA), myValue, MutationRef::AppendIfFits);

loop {
try {
tr.set(StringRef(clientID + "z/" + myRandomIDKey), StringRef());
tr.atomicOp(StringRef(clientID + "d/" + myKeyA), myValue, MutationRef::AppendIfFits);
Void _ = wait( tr.commit() );
break;
} catch (Error& e) {
error = e;
Void _ = wait( tr.onError(e) );
if(error.code() == error_code_commit_unknown_result) {
Optional<Value> thing = wait(tr.get(StringRef(clientID+"z/"+myRandomIDKey)));
if (thing.present()) break;
}
}
}
}
else if( j < 9 ) {
myKeyA = format( "%010d", g_random->randomInt( 0, self->maxKeySpace+1 ) );
myRandomIDKey = format( "%010d", g_random->randomInt(0, 1000000000) );
myValue = format("%d", g_random->randomInt( 0, 10000000 ) );
Expand All @@ -283,7 +283,7 @@ struct RandomSelectorWorkload : TestWorkload {
}
}
}
else if( j < 9 ) {
else if( j < 10 ) {
myKeyA = format( "%010d", g_random->randomInt( 0, self->maxKeySpace+1 ) );
myRandomIDKey = format( "%010d", g_random->randomInt(0, 1000000000) );
myValue = format("%d", g_random->randomInt( 0, 10000000 ) );
Expand All @@ -306,7 +306,7 @@ struct RandomSelectorWorkload : TestWorkload {
}
}
}
else if( j < 10 ) {
else if( j < 11 ) {
myKeyA = format( "%010d", g_random->randomInt( 0, self->maxKeySpace+1 ) );
myRandomIDKey = format( "%010d", g_random->randomInt(0, 1000000000) );
myValue = format("%d", g_random->randomInt( 0, 10000000 ) );
Expand All @@ -329,7 +329,7 @@ struct RandomSelectorWorkload : TestWorkload {
}
}
}
else if (j < 11) {
else if (j < 12) {
myKeyA = format("%010d", g_random->randomInt(0, self->maxKeySpace + 1));
myRandomIDKey = format("%010d", g_random->randomInt(0, 1000000000));
myValue = format("%d", g_random->randomInt(0, 10000000));
Expand All @@ -353,7 +353,7 @@ struct RandomSelectorWorkload : TestWorkload {
}
}
}
else if (j < 12) {
else if (j < 13) {
myKeyA = format("%010d", g_random->randomInt(0, self->maxKeySpace + 1));
myRandomIDKey = format("%010d", g_random->randomInt(0, 1000000000));
myValue = format("%d", g_random->randomInt(0, 10000000));
Expand All @@ -377,7 +377,7 @@ struct RandomSelectorWorkload : TestWorkload {
}
}
}
else if (j < 13) {
else if (j < 14) {
myKeyA = format("%010d", g_random->randomInt(0, self->maxKeySpace + 1));
myRandomIDKey = format("%010d", g_random->randomInt(0, 1000000000));
myValue = format("%d", g_random->randomInt(0, 10000000));
Expand All @@ -401,7 +401,7 @@ struct RandomSelectorWorkload : TestWorkload {
}
}
}
else if (j < 14) {
else if (j < 15) {
myKeyA = format("%010d", g_random->randomInt(0, self->maxKeySpace + 1));
myRandomIDKey = format("%010d", g_random->randomInt(0, 1000000000));
myValue = format("%d", g_random->randomInt(0, 10000000));
Expand Down