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

Fix idea: concurrency control using last-read-wins global variable (suggestions welcome) #1006

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

hlin-neo4j
Copy link

@hlin-neo4j hlin-neo4j commented Nov 27, 2024

For example, the issue is, I have a dashboard with a parameter select card and a Single Value card. I choose parameter X, the single value card should update, but the query takes a while to run, so it shows it's loading. While the query is running, I choose another parameter, triggering the query to run again, but it returns before the first, and updates the single value card. When the first query finally finishes, the single value card gets updated again, incorrectly, with a now-stale value.

Ideally, any transaction about to run against Neo4j should cancel any currently running transactions that shares the same query, but this wasn't trivial and/or not possible to do at the time. Currently, afaik with the source code, all transactions in reports are allowed to run. And so, I dealt with this at the frontend layer. Specifically, I created a global redux variable lastPopulateQueryTimestamp associated with the Card state that tracks/represents the latest call of the query. This is set whenever a query is run. When the transaction returns, the logic checks if its timestamp is the same as the global, and only if so, sets the records. In order to get access to that current store inside a non-react component, I had to implement a GET thunk to read and return it. I wrapped it in a dispatch and passed it down the functions so the post-await block is able to access the store.

Copy link

sonarqubecloud bot commented Dec 6, 2024

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

Successfully merging this pull request may close these issues.

1 participant