ArcticDB
ArcticDB copied to clipboard
Figure out and document how to concurrently backfill and append to a symbol
trafficstars
From @jamesmunro
Implementation question. I think this could be a common use case. I've got a process that appends new rows to a symbol whenever new bars/ticks arrive.
while True:
df = read_ticks(asset_id)
lib.append(asset_id, df)
I want to separately change, replace or backfill the history. The rows I'm changing are before those of the last append. How can I do that without the risk of losing the rows in one of those appends, or losing the update?
# manual backfill of history from separate process
df = build_backfill(asset_id, endofdayyesterday)
lib.update(asset_id, df)
One idea is to use staged.
Appending process:
while True:
df = read_ticks(asset_id)
lib.append(asset_id, df, staged=True)
lib.finalize_staged_data(asset_id)
Meddling process:
df = build_backfill(asset_id, endofdayyesterday)
lib.update(asset_id, df, staged=True)
Are we think that finalize_staged_data works simultaneous with other staged writes? Is any synchronisation necessary?