ArcticDB icon indicating copy to clipboard operation
ArcticDB copied to clipboard

Figure out and document how to concurrently backfill and append to a symbol

Open poodlewars opened this issue 2 years ago • 0 comments
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?

poodlewars avatar Aug 23 '23 09:08 poodlewars