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

feat: add MongoDB functions to handle transactions #96

Merged

Conversation

patriciareinoso
Copy link
Contributor

This PR adds 4 functions needed to handle transactions in mongoDB.

We would like to use transactions to ensure Atomicity in operations that perform 2 or more actions over the DB. With transactions, the operations are rolled back in case of failure. https://www.mongodb.com/docs/manual/core/transactions/

Transactions can only be used in Replica Set or sharded deployments.

Operations in a transaction use a shared mongo.SessionContext instead of separate context.TODO()

@thakurajayL
Copy link
Contributor

HI @patriciareinoso - Where you plan to use the transaction feature?

@patriciareinoso
Copy link
Contributor Author

HI @patriciareinoso - Where you plan to use the transaction feature?

Hi @thakurajayL omec-project/webconsole#279 We are trying to ensure consistency in the DB after a DELETE operation. In the PR we would like to DELETE the reference to the gNB or UPF in a Network Slice after they are deleted. The idea is to do this also when deleting a Subscriber (-> remove the reference in the "imsis" list of Device Groups) and deleting Device Groups (-> remove the reference in the "site-device-group" list of Network Slices)

@gab-arrobo gab-arrobo merged commit 09af132 into omec-project:main Jan 15, 2025
10 checks passed
thakurajayL pushed a commit that referenced this pull request Jan 16, 2025
* add MongoDB functions to handle transactions

Signed-off-by: Patricia Reinoso <[email protected]>

* rename to supports transactions

Signed-off-by: Patricia Reinoso <[email protected]>

---------

Signed-off-by: Patricia Reinoso <[email protected]>
Signed-off-by: Ajay Lotan Thakur <[email protected]>
gab-arrobo pushed a commit that referenced this pull request Jan 16, 2025
* Updates in the logs

Signed-off-by: Ajay Lotan Thakur <[email protected]>

* Bump github.com/gin-contrib/cors in /mongoapi/dbtestapp (#94)

Signed-off-by: Ajay Lotan Thakur <[email protected]>

* Fixing API errors

Signed-off-by: Ajay Lotan Thakur <[email protected]>

* Update drsm/api.go

Co-authored-by: gab-arrobo <[email protected]>
Signed-off-by: Ajay Lotan Thakur <[email protected]>

* Update drsm/api.go

Co-authored-by: gab-arrobo <[email protected]>
Signed-off-by: Ajay Lotan Thakur <[email protected]>

* Update drsm/api.go

Co-authored-by: gab-arrobo <[email protected]>
Signed-off-by: Ajay Lotan Thakur <[email protected]>

* Update drsm/chunk.go

Co-authored-by: gab-arrobo <[email protected]>
Signed-off-by: Ajay Lotan Thakur <[email protected]>

* Update drsm/claim.go

Co-authored-by: gab-arrobo <[email protected]>
Signed-off-by: Ajay Lotan Thakur <[email protected]>

* Fix typo and update logging level

Signed-off-by: Ajay Lotan Thakur <[email protected]>

* feat: add MongoDB functions to handle transactions (#96)

* add MongoDB functions to handle transactions

Signed-off-by: Patricia Reinoso <[email protected]>

* rename to supports transactions

Signed-off-by: Patricia Reinoso <[email protected]>

---------

Signed-off-by: Patricia Reinoso <[email protected]>
Signed-off-by: Ajay Lotan Thakur <[email protected]>

* Update drsm/api.go

Co-authored-by: gab-arrobo <[email protected]>
Signed-off-by: Ajay Lotan Thakur <[email protected]>

---------

Signed-off-by: Ajay Lotan Thakur <[email protected]>
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