Skip to content

Commit

Permalink
Fixes flaky persistant storage lock test
Browse files Browse the repository at this point in the history
The persistant storage test was deemed flaky because of occasional
`XAmzContentSHA256Mismatch` errors. This was beause of a faulty
multiprocessing sharing of an s3 library. So we reconstruct the `Library` object in each process.

Also upgrades the aws-sdk-cpp (a red herring lead to upgrading the sdk
but didn't fix the issue). Still it's a good change so keeping it.
  • Loading branch information
IvoDD committed Jan 27, 2025
1 parent a097b2c commit b3a8deb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cpp/vcpkg
Submodule vcpkg updated 1686 files
8 changes: 6 additions & 2 deletions cpp/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
},
{
"name": "aws-crt-cpp",
"version>=": "0.28.3"
"version>=": "0.29.7"
},
{
"name": "aws-c-mqtt",
"version>=": "0.11.0"
},
{
"name": "aws-c-s3",
Expand Down Expand Up @@ -104,7 +108,7 @@
],
"overrides": [
{ "name": "openssl", "version-string": "3.3.0" },
{ "name": "aws-sdk-cpp", "version": "1.11.405" },
{ "name": "aws-sdk-cpp", "version": "1.11.474" },
{ "name": "azure-core-cpp", "version": "1.12.0" },
{ "name": "benchmark", "version": "1.9.0" },
{ "name": "bitmagic", "version": "7.12.3" },
Expand Down
22 changes: 13 additions & 9 deletions python/tests/integration/arcticdb/test_storage_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys

from arcticdb_ext.tools import ReliableStorageLock, ReliableStorageLockManager
from tests.util.mark import PERSISTENT_STORAGE_TESTS_ENABLED, REAL_S3_TESTS_MARK
from tests.util.mark import REAL_S3_TESTS_MARK

import time

Expand All @@ -15,7 +15,13 @@
one_sec = 1_000_000_000


def slow_increment_task(lib, symbol, sleep_time, lock_manager, lock):
def slow_increment_task(real_s3_storage_factory, lib_name, symbol, sleep_time):
# We need to explicitly build the library object in each process, otherwise the s3 library doesn't get copied
# properly between processes, and we get spurious `XAmzContentSHA256Mismatch` errors.
fixture = real_s3_storage_factory.create_fixture()
lib = fixture.create_arctic()[lib_name]
lock = ReliableStorageLock("test_lock", lib._nvs._library, 10 * one_sec)
lock_manager = ReliableStorageLockManager()
lock_manager.take_lock_guard(lock)
df = lib.read(symbol).data
df["col"][0] = df["col"][0] + 1
Expand All @@ -24,20 +30,18 @@ def slow_increment_task(lib, symbol, sleep_time, lock_manager, lock):
lock_manager.free_lock_guard()


@pytest.mark.skip(reason="This test is flaky, skip it temporarily")
@pytest.mark.parametrize("num_processes,max_sleep", [(100, 1), (5, 20)])
@REAL_S3_TESTS_MARK
def test_many_increments(real_s3_version_store, num_processes, max_sleep):
lib = real_s3_version_store
def test_many_increments(real_s3_storage_factory, lib_name, num_processes, max_sleep):
fixture = real_s3_storage_factory.create_fixture()
lib = fixture.create_arctic().create_library(lib_name)
init_df = pd.DataFrame({"col": [0]})
symbol = "counter"
lib.version_store.force_delete_symbol(symbol)
lib._nvs.version_store.force_delete_symbol(symbol)
lib.write(symbol, init_df)
lock = ReliableStorageLock("test_lock", lib._library, 10 * one_sec)
lock_manager = ReliableStorageLockManager()

processes = [
Process(target=slow_increment_task, args=(lib, symbol, 0 if i % 2 == 0 else max_sleep, lock_manager, lock))
Process(target=slow_increment_task, args=(real_s3_storage_factory, lib_name, symbol, 0 if i % 2 == 0 else max_sleep))
for i in range(num_processes)
]
for p in processes:
Expand Down

0 comments on commit b3a8deb

Please sign in to comment.