Skip to content

Commit

Permalink
WT-5675 Prepare support workgen changes (#5453)
Browse files Browse the repository at this point in the history
* WT-5675 Prepare support workgen changes
*  Encapsulated timestamps to use epoch time
* Added oldest, stable timestamps to move forward periodically
* Moved irrelevant functions from Workload to WorkloadRunner class
* Renamed _transaction to transaction in all related files
  • Loading branch information
raviprakashgiri29 committed Apr 8, 2020
1 parent 760c4c1 commit 98eb938
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 37 deletions.
78 changes: 78 additions & 0 deletions bench/workgen/runner/example_prepare.py
@@ -0,0 +1,78 @@
#!/usr/bin/env python
#
# Public Domain 2014-2020 MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#

from runner import *
from wiredtiger import *
from workgen import *

conn = wiredtiger_open("WT_TEST", "create,cache_size=500MB")
s = conn.open_session()
tname = "table:test"
config = "key_format=S,value_format=S,"
s.create(tname, config)
table = Table(tname)
table.options.key_size = 20
table.options.value_size = 10

context = Context()
op = Operation(Operation.OP_INSERT, table)
thread = Thread(op * 5000)
pop_workload = Workload(context, thread)
print('populate:')
pop_workload.run(conn)

opread = Operation(Operation.OP_SEARCH, table)
read_txn = txn(opread * 10, 'read_timestamp')
# read_timestamp_lag is the lag to the read_timestamp from current time
read_txn.transaction.read_timestamp_lag = 5
treader = Thread(read_txn)

opwrite = Operation(Operation.OP_INSERT, table)
write_txn = txn(opwrite * 10, 'isolation=snapshot')
# use_prepare_timestamp - Commit the transaction with stable_timestamp.
write_txn.transaction.use_prepare_timestamp = True
twriter = Thread(write_txn)

opupdate = Operation(Operation.OP_UPDATE, table)
update_txn = txn(opupdate * 10, 'isolation=snapshot')
# use_commit_timestamp - Commit the transaction with commit_timestamp.
update_txn.transaction.use_commit_timestamp = True
tupdate = Thread(update_txn)

workload = Workload(context, 10 * twriter + 10 * tupdate + 10 * treader)
workload.options.run_time = 50
workload.options.report_interval=500
# read_timestamp_lag - Number of seconds lag to the oldest_timestamp from current time.
workload.options.oldest_timestamp_lag=30
# read_timestamp_lag - Number of seconds lag to the stable_timestamp from current time.
workload.options.stable_timestamp_lag=10
# timestamp_advance is the number of seconds to wait before moving oldest and stable timestamp.
workload.options.timestamp_advance=1
print('transactional prepare workload:')
workload.run(conn)
4 changes: 2 additions & 2 deletions bench/workgen/runner/runner/core.py
Expand Up @@ -35,7 +35,7 @@
# Put the operation (and any suboperations) within a transaction.
def txn(op, config=None):
t = Transaction(config)
op._transaction = t
op.transaction = t
return op

# sleep --
Expand Down Expand Up @@ -301,7 +301,7 @@ def _op_transaction_list(oplist, txn_config):
def op_group_transaction(ops_arg, ops_per_txn, txn_config):
if ops_arg != Operation.OP_NONE:
return txn(ops_arg, txn_config)
if ops_arg._transaction != None:
if ops_arg.transaction != None:
raise Exception('nested transactions not supported')
if ops_arg._repeatgroup != None:
raise Exception('grouping transactions with multipliers not supported')
Expand Down

0 comments on commit 98eb938

Please sign in to comment.