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

sql: lease flaw #3517

Closed
ndr-brt opened this issue Oct 6, 2023 · 0 comments
Closed

sql: lease flaw #3517

ndr-brt opened this issue Oct 6, 2023 · 0 comments
Assignees
Labels
bug_report Suspected bugs, awaiting triage triage all new issues awaiting classification

Comments

@ndr-brt
Copy link
Member

ndr-brt commented Oct 6, 2023

Bug Report

Describe the Bug

We're not handling the lease correctly when we update an entity, e.g.

leaseContext.by(leaseHolderName).withConnection(conn).breakLease(entity.getId());
update(conn, entity, existing.getDataRequest().getId());

or

(it's like this pretty much on every sql store implementation).

Expected Behavior

The correct behavior is shown in the delete implementation:

// attempt to acquire lease - should fail if someone else holds the lease
leaseContext.withConnection(connection).acquireLease(negotiationId);
var stmt = statements.getDeleteTemplate();
queryExecutor.execute(connection, stmt, negotiationId);
//necessary to delete the row in edc_lease
leaseContext.withConnection(connection).breakLease(negotiationId);

we should acquire the lease BEFORE executing the update statement, and the breakLease should happen after it.

Possible Implementation

To have this working in the correct way, the acquireLease method should change a bit:

if (lease != null && !lease.isExpired(clock)) {
throw new IllegalStateException("Entity is currently leased!");
}

it should not fail when the acquireLease is ran by the lease holder, in this case likely it should "renew" the lease.

In fact this flaw could be somehow related to #3514

@ndr-brt ndr-brt added bug_report Suspected bugs, awaiting triage triage all new issues awaiting classification labels Oct 6, 2023
@ndr-brt ndr-brt self-assigned this Oct 6, 2023
@ndr-brt ndr-brt added bug Something isn't working and removed bug_report Suspected bugs, awaiting triage triage all new issues awaiting classification labels Oct 6, 2023
@ndr-brt ndr-brt added this to the Milestone 12 milestone Oct 6, 2023
@ndr-brt ndr-brt added bug_report Suspected bugs, awaiting triage triage all new issues awaiting classification and removed bug Something isn't working labels Oct 6, 2023
@ndr-brt ndr-brt removed this from the Milestone 12 milestone Oct 6, 2023
@ndr-brt ndr-brt closed this as completed Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug_report Suspected bugs, awaiting triage triage all new issues awaiting classification
Projects
None yet
Development

No branches or pull requests

1 participant