Skip to content
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
11 changes: 11 additions & 0 deletions python_tests/memo_test_types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from dataclasses import dataclass
import dbzero as db0
from datetime import datetime

Expand Down Expand Up @@ -220,3 +221,13 @@ def __init__(self, type, processor_type, data = None, key = None, parent = None,
self.child_tasks = []
self.requirements = requirements
self.max_retry = None


RANDOM_BYTES = b'DB0'*100000

@db0.memo(no_default_tags=True)
@dataclass
class MemoBlob:
def __init__(self, size_bytes: int):
assert size_bytes <= len(RANDOM_BYTES)
self.data = RANDOM_BYTES[:size_bytes]
25 changes: 25 additions & 0 deletions python_tests/test_issues_11.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import dbzero as db0
import pytest
from .conftest import DB0_DIR
from datetime import datetime
from .memo_test_types import MemoBlob
import random


@pytest.mark.stress_test
@pytest.mark.parametrize("db0_slab_size", [{"slab_size": 64 << 20, "autocommit": False}], indirect=True)
def test_wide_lock_badaddr_issue(db0_slab_size):
db0.set_cache_size(8 << 30)
all_blobs = db0.list()
append_count = 300289
# append large blobs to force wide locks
for count in range(append_count):
all_blobs.append(MemoBlob(24 << 10))
if count % 50000 == 0:
print("Commit...")
db0.commit()
print(f"Appended {count} blobs")

# faulty operation
all_blobs.append(MemoBlob(24 << 10))

Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ DB0_PACKED_END
typename ItemEqualType,
typename CompressedItemEqualType,
typename CapacityType = std::uint16_t,
typename AddressType = std::uint32_t,
typename AddressType = std::uint64_t,
typename HeaderType = db0::o_null,
typename TreeHeaderType = db0::o_null>
class sgb_compressed_lookup_types
Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/core/collections/SGB_Tree/SGB_LookupTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ DB0_PACKED_END
typename ItemCompType,
typename ItemEqualType,
typename CapacityType = std::uint16_t,
typename AddressType = std::uint32_t,
typename AddressType = std::uint64_t,
typename HeaderType = db0::o_null,
typename TreeHeaderType = db0::o_null>
class sgb_lookup_types
Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/core/collections/SGB_Tree/SGB_Tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ namespace db0
* @tparam HeaderT optional fixed-size header to be associated with each node / block (default is none / null), helpful when implementing extensions
*/
template <typename ItemT, typename ItemCompT = std::less<ItemT>, typename ItemEqualT = std::equal_to<ItemT>,
typename CapacityT = std::uint16_t, typename AddressT = std::uint32_t, typename HeaderT = o_null, typename TreeHeaderT = o_null>
typename CapacityT = std::uint16_t, typename AddressT = std::uint64_t, typename HeaderT = o_null, typename TreeHeaderT = o_null>
class SGB_Tree: public SGB_TreeBase<sgb_types<ItemT, ItemCompT, ItemEqualT, CapacityT, AddressT, HeaderT, TreeHeaderT> >
{
using super_t = SGB_TreeBase<sgb_types<ItemT, ItemCompT, ItemEqualT, CapacityT, AddressT, HeaderT, TreeHeaderT> >;
Expand Down
6 changes: 3 additions & 3 deletions src/dbzero/core/memory/AlgoAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace db0
{
}

std::optional<Address> AlgoAllocator::tryAlloc(std::size_t size, std::uint32_t slot_num,
std::optional<Address> AlgoAllocator::tryAlloc(std::size_t size, std::uint32_t slot_num,
bool aligned, unsigned char)
{
assert(slot_num == 0);
assert(!aligned && "AlgoAllocator: aligned allocation not supported");
assert(!aligned && "AlgoAllocator: aligned allocation not supported");
assert(size == m_alloc_size && "AlgoAllocator: invalid alloc size requested");
return m_address_pool_f(m_next_i++);
}
Expand Down Expand Up @@ -63,7 +63,7 @@ namespace db0
void AlgoAllocator::reset() {
m_next_i = 0;
}

Address AlgoAllocator::getRootAddress() const {
return m_address_pool_f(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/dbzero/core/memory/MetaAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ namespace db0

void MetaAllocator::formatPrefix(std::shared_ptr<Prefix> prefix, std::size_t page_size, std::size_t slab_size)
{
// create the meta-header and the address 0x0
// create the meta-header at the address 0x0
OneShotAllocator one_shot(Address::fromOffset(0), o_meta_header::sizeOf());
Memspace memspace(Memspace::tag_from_reference(), prefix, one_shot);
v_object<o_meta_header> meta_header(memspace, page_size, slab_size);
Expand Down