-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only write ref key once when writing with prune_previous_versions (#1560
) #### What does this implement or fix? We should only write the version ref key once when we write with `prune_previous_versions=True`. Currently we are writing it twice - once after we write the tombstone all and once when we write the new version. This means that there is a period of time where the symbol is unreadable. This was fixed a while ago with PR #1104 but regressed with PR #1355.
- Loading branch information
1 parent
259d1bd
commit d2e49ff
Showing
3 changed files
with
69 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
python/tests/stress/arcticdb/version_store/test_concurrent_read_and_write.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import time | ||
import pytest | ||
from multiprocessing import Process, Queue | ||
|
||
|
||
@pytest.fixture | ||
def writer_store(lmdb_version_store_delayed_deletes_v2): | ||
return lmdb_version_store_delayed_deletes_v2 | ||
|
||
|
||
@pytest.fixture | ||
def reader_store(lmdb_version_store_delayed_deletes_v2): | ||
return lmdb_version_store_delayed_deletes_v2 | ||
|
||
|
||
def read_repeatedly(version_store, queue: Queue): | ||
while True: | ||
try: | ||
version_store.read("sym") | ||
except Exception as e: | ||
queue.put(e) | ||
raise # don't get stuck in the while loop when we already know there's an issue | ||
time.sleep(0.1) | ||
|
||
|
||
def write_repeatedly(version_store): | ||
while True: | ||
version_store.write("sym", [1, 2, 3], prune_previous_version=True) | ||
time.sleep(0.1) | ||
|
||
|
||
def test_concurrent_read_write(writer_store, reader_store): | ||
"""When using delayed deletes, a reader should always be able to read a symbol even if it is being modified | ||
and pruned by another process.""" | ||
writer_store.write("sym", [1, 2, 3], prune_previous_version=True) | ||
exceptions_in_reader = Queue() | ||
reader = Process(target=read_repeatedly, args=(reader_store, exceptions_in_reader)) | ||
writer = Process(target=write_repeatedly, args=(writer_store,)) | ||
|
||
try: | ||
reader.start() | ||
writer.start() | ||
reader.join(5) | ||
writer.join(0.001) | ||
finally: | ||
writer.terminate() | ||
reader.terminate() | ||
|
||
assert exceptions_in_reader.empty() |