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: Improve Lock Manager HTTP layer #15

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

fmarek-kindred
Copy link
Contributor

No description provided.

README.md Outdated
@@ -408,7 +423,7 @@ Similarly run git server for "remote test app"
scripts/host-project-in-git.sh /tmp/remote-sample $(pwd)/../examples/graph-perf-test-app
```

Please note that when these projects will be feetched from local git by `k8-deployer`, the fetched project will have no `.env` file! However, our deployment scripts under `deployment/pit/*` can locate `.env` file by reading global environment variables. This is intended for local development. Below is the list of global environment variables
Please note that when these projects will be feetched from local git by `k8-deployer`, the fetched project will have no `.env` file! However, our deployment scripts under `deployment/pit/*` can locate `.env` file by reading global environment variables. This is intended for local development. Below is the list of global environment variables
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo feetched -> fetched

}

const result = await db.execute(query)

let unlockedKeys = result?.rows?.map(({ lock_id }) => lock_id)
if (unlockedKeys?.length === 0) {
throw new Error("release(): No valid lock and owner combination found in database to delete")
throw new Error("No valid lock and owner combination found in database to delete")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Should this be treated as an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not matter as long as caller knows what to do. For example if user1 not owning a lock but trying to release it, this will produce error because "user1 + lockid" is not known. Similar with keep alive. service. Using errors gives us just 2 states: error or success. If we do not want to use error then we ned three states, which is harder to code maybe :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say that releasing a previously held lock (by deleting an existing record) and having no lock to release yield the same outcomes for the caller. They are effectively idempotent. This shouldn't be treated as an error.

logger.warn("http-client.invoke(): attempt %s of %s invoking %s. Error: %s", attempts, options.retries, JSON.stringify(options.fetchParams), error)
if (attempts < options.retries) {
attempts++
await sleep(options.retryDelay)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we have this sleep in the invoke method, maybe we should remove this sleep while trying to acquire lock, else we are going to sleep longer duration than necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense to remove the second one.

Copy link
Collaborator

@gk-kindred gk-kindred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please have a look at the comments?

@fmarek-kindred fmarek-kindred force-pushed the feature/lock-manager-work branch from fc41546 to f0cbde3 Compare February 13, 2024 04:49
@fmarek-kindred fmarek-kindred merged commit 4a024aa into master Feb 13, 2024
1 check passed
@fmarek-kindred fmarek-kindred deleted the feature/lock-manager-work branch February 13, 2024 04:50
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.

3 participants