Commit ab3ca24e authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1125 Fix a couple of off-by-one errors with xids (max level of nested transactions)

Added tests that check all message types/changes you can do to a non-existant leafentry
Added tests that check all message types/changes you can do to a committed (insert) leafentry

git-svn-id: file:///svn/toku/tokudb@13529 c7de825b-a66e-492c-adef-691d508d4ae1
parent 56f59827
This diff is collapsed.
...@@ -206,7 +206,7 @@ msg_init_empty_ule(ULE ule, BRT_MSG msg) { ...@@ -206,7 +206,7 @@ msg_init_empty_ule(ULE ule, BRT_MSG msg) {
static void static void
msg_modify_ule(ULE ule, BRT_MSG msg) { msg_modify_ule(ULE ule, BRT_MSG msg) {
XIDS xids = brt_msg_get_xids(msg); XIDS xids = brt_msg_get_xids(msg);
assert(xids_get_num_xids(xids) < MAX_TRANSACTION_RECORDS); assert(xids_get_num_xids(xids) <= MAX_TRANSACTION_RECORDS);
ule_do_implicit_promotions(ule, xids); ule_do_implicit_promotions(ule, xids);
brt_msg_type type = brt_msg_get_type(msg); brt_msg_type type = brt_msg_get_type(msg);
switch (type) { switch (type) {
...@@ -684,7 +684,8 @@ le_full_promotion(LEAFENTRY le, ...@@ -684,7 +684,8 @@ le_full_promotion(LEAFENTRY le,
assert(le); assert(le);
assert(le->num_xrs > 1); //Not committed assert(le->num_xrs > 1); //Not committed
assert(!le_is_provdel(le)); assert(!le_is_provdel(le));
assert(le_outermost_uncommitted_xid(le) != 0); TXNID outermost_uncommitted_xid = le_outermost_uncommitted_xid(le);
assert(outermost_uncommitted_xid != 0);
size_t old_memsize = leafentry_memsize(le); size_t old_memsize = leafentry_memsize(le);
u_int32_t old_keylen; u_int32_t old_keylen;
...@@ -705,12 +706,15 @@ le_full_promotion(LEAFENTRY le, ...@@ -705,12 +706,15 @@ le_full_promotion(LEAFENTRY le,
BRT_MSG_S slow_full_promotion_msg = { BRT_MSG_S slow_full_promotion_msg = {
.type = BRT_COMMIT_ANY, .type = BRT_COMMIT_ANY,
.xids = xids_get_root_xids(),
.u.id = { .u.id = {
.key = NULL, .key = NULL,
.val = NULL, .val = NULL,
} }
}; };
int r_xids = xids_create_child(xids_get_root_xids(),
&slow_full_promotion_msg.xids,
outermost_uncommitted_xid);
assert(r_xids==0);
size_t slow_new_memsize; size_t slow_new_memsize;
size_t slow_new_disksize; size_t slow_new_disksize;
LEAFENTRY slow_le; LEAFENTRY slow_le;
...@@ -771,6 +775,7 @@ le_full_promotion(LEAFENTRY le, ...@@ -771,6 +775,7 @@ le_full_promotion(LEAFENTRY le,
assert(memcpy(new_key, old_key, old_keylen) == 0); assert(memcpy(new_key, old_key, old_keylen) == 0);
assert(memcpy(new_val, old_val, old_vallen) == 0); assert(memcpy(new_val, old_val, old_vallen) == 0);
xids_destroy(&slow_full_promotion_msg.xids);
toku_free(slow_le); toku_free(slow_le);
toku_free(old_key); toku_free(old_key);
toku_free(old_val); toku_free(old_val);
......
...@@ -69,11 +69,11 @@ xids_create_child(XIDS parent_xids, // xids list for parent transaction ...@@ -69,11 +69,11 @@ xids_create_child(XIDS parent_xids, // xids list for parent transaction
int rval; int rval;
assert(parent_xids); assert(parent_xids);
assert(this_xid > xids_get_innermost_xid(parent_xids)); assert(this_xid > xids_get_innermost_xid(parent_xids));
u_int8_t num_stored_xids = parent_xids->num_stored_xids + 1; u_int32_t num_stored_xids = parent_xids->num_stored_xids + 1;
u_int8_t num_xids = num_stored_xids + 1; u_int32_t num_xids = num_stored_xids + 1;
assert(num_xids > 0); assert(num_xids > 0);
assert(num_xids <= MAX_TRANSACTION_RECORDS); assert(num_xids <= MAX_TRANSACTION_RECORDS + 1);
if (num_xids == MAX_TRANSACTION_RECORDS) rval = EINVAL; if (num_xids > MAX_TRANSACTION_RECORDS) rval = EINVAL;
else { else {
XIDS xids = toku_malloc(sizeof(*xids) + num_stored_xids*sizeof(xids->ids[0])); XIDS xids = toku_malloc(sizeof(*xids) + num_stored_xids*sizeof(xids->ids[0]));
if (!xids) rval = ENOMEM; if (!xids) rval = ENOMEM;
...@@ -94,10 +94,10 @@ xids_create_child(XIDS parent_xids, // xids list for parent transaction ...@@ -94,10 +94,10 @@ xids_create_child(XIDS parent_xids, // xids list for parent transaction
void void
xids_create_from_buffer(struct rbuf *rb, // xids list for parent transaction xids_create_from_buffer(struct rbuf *rb, // xids list for parent transaction
XIDS * xids_p) { // xids list created XIDS * xids_p) { // xids list created
u_int8_t num_stored_xids = rbuf_char(rb); u_int32_t num_stored_xids = rbuf_char(rb);
u_int8_t num_xids = num_stored_xids + 1; u_int32_t num_xids = num_stored_xids + 1;
assert(num_xids > 0); assert(num_xids > 0);
assert(num_xids < MAX_TRANSACTION_RECORDS); assert(num_xids <= MAX_TRANSACTION_RECORDS);
XIDS xids = toku_xmalloc(sizeof(*xids) + num_stored_xids*sizeof(xids->ids[0])); XIDS xids = toku_xmalloc(sizeof(*xids) + num_stored_xids*sizeof(xids->ids[0]));
xids->num_stored_xids = num_stored_xids; xids->num_stored_xids = num_stored_xids;
u_int8_t index; u_int8_t index;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment