Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafe access to state in multi-threaded operators #105

Open
pschafhalter opened this issue Mar 26, 2020 · 0 comments
Open

Unsafe access to state in multi-threaded operators #105

pschafhalter opened this issue Mar 26, 2020 · 0 comments

Comments

@pschafhalter
Copy link
Member

pschafhalter commented Mar 26, 2020

Currently, access to state isn't locked. When using the TimeVersionedState, we could introduce unsafe accesses due to concurrency if a watermark callback for time t and a data callback for time t + 1 run simultaneously.

Currently, this shouldn't cause problems because only 1 callback can access state at a time. In the future, we may want to increase parallelism in multi-threaded operators and then this will cause problems.

Lines causing the problem (also in scripts/make_callback_builder.py):

let state_ref_mut =
unsafe { Arc::get_mut_unchecked(&mut state_arc) };
state_ref_mut.set_access_context(AccessContext::Callback);
state_ref_mut.set_current_time(msg.timestamp.clone());
(callback)(msg_copy.timestamp, msg_copy.data, state_ref_mut)

Potential solutions:

  1. Locking.
  2. Cloning.
  3. Providing a view on a subsection of the state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant