abpframework / abpframework/abp

Locking on UoW lifetime

Open
#24,046 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
C#
Stars
14.4k
Forks
3.7k
Avg merge
15h 32m
Merged PRs (30d)
106

Description

Is there an existing issue for this?
  • I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.

We have some cases where database changes need to be persistent in order when parallel access/updates happen.

This is tricky, because database changes (usually) happen when the UoW completes and this is in most cases after the method has finished / exit. So most locking methods are not usable (when the automatic UoW handling is used). And its gets more complicated when multiple UoW levels are involved.

A example would be a data string, that needs to be processed and updated with the result of each processing step.

Using a distributed lock would work, but only if the lock release is bonded to UoW lifetime. If multiple actions can happen in the same UoW, you need to check if this lock is already acquired by this UoW or this might cause a deadlock.

(a solution for the example would be to split it up to multiple entities but that approach has other synchronization issues)

Describe the solution you'd like

A extension for IAbpDistributedLock to lock on UoW level and release when its completed / failed.

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading IAbpDistributedLock and the unit-of-work lifecycle described in the issue, then trace how nested units of work complete or fail. Define how a lock is acquired, reused within the same unit of work, and released on completion or failure; done requires a concrete design and tests covering parallel access and nested units of work.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.