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: Synchronize EDR refresh #1633

Merged

Conversation

rafaelmag110
Copy link
Contributor

@rafaelmag110 rafaelmag110 commented Oct 17, 2024

WHAT

Introduces a synchronization mechanism with database locks that only allows one request to update an expired token at a time. All other requests wait until the first request updates the token and releases the database.

WHY

To fix the issue described in #1618

FURTHER NOTES

PR to bugfix/0.7.7 first because it's a priority to have that merged.

Closes #1618

@rafaelmag110 rafaelmag110 added the bug Something isn't working label Oct 17, 2024
@rafaelmag110 rafaelmag110 requested review from paullatzelsperger and wolf4ood and removed request for paullatzelsperger October 17, 2024 14:17
@rafaelmag110 rafaelmag110 force-pushed the synchronize_edr_refresh branch from aecad9a to 944ff4d Compare October 17, 2024 17:29
@paullatzelsperger
Copy link
Contributor

paullatzelsperger commented Oct 22, 2024

Actually, regarding the inmem lock; if access to the hashmap is atomic, the global lock isn't needed anymore.
We either don't implement any locking in the inmem variant, or we use a concurrent hashmap w rowlevel locks, or a global lock. In sequence of (my personal) preference :)

@rafaelmag110
Copy link
Contributor Author

Actually, regarding the inmem lock; if access to the hashmap is atomic, the global lock isn't needed anymore. We either don't implement any locking in the inmem variant, or we use a concurrent hashmap w rowlevel locks, or a global lock. In sequence of (my personal) preference :)

Can't see how we can make it without row-level locks. Remember the row has to keep locked until the token is refreshed, that's how we keep its state consistent. I went for option two from your list.

@paullatzelsperger
Copy link
Contributor

paullatzelsperger commented Oct 23, 2024

Can't see how we can make it without row-level locks. Remember the row has to keep locked until the token is refreshed, that's how we keep its state consistent. I went for option two from your list.

we could completely leave out locking altogether - this is the in-mem store, and it's not suited for production anyways.

without row-level locks (i.e. only a global one), we'd effectively synchronize on the EDR store, which to me would be fine because - again this is in-mem-land.

Option 2 is fine though.

Copy link

sonarcloud bot commented Oct 23, 2024

@rafaelmag110
Copy link
Contributor Author

all ✅
🚀

@wolf4ood wolf4ood merged commit c8cd9d6 into eclipse-tractusx:bugfix/0.7.7 Oct 23, 2024
27 checks passed
rafaelmag110 added a commit to rafaelmag110/tractusx-edc that referenced this pull request Oct 23, 2024
* Failing test and added code to make it pass

* Created module for EdrLockSql and added statements

* alter test to check for correct response

* remove debug messages

* Introduce InMemoryEdrLock

* working version

* improve test for two different edrs.

* code dup

* refactor inmem acquireLock

* handle

* handle2

* refactor in mem EDR lock

* update EdrServiceImpl to enable force refresh

* Remove non existing job from verify.yaml

* Add ComponentTests

* fix failing uts

* Removes global lock in inmem variant

* inmem release lock should be atomic

* retrigger CI

* retrigger CI
wolf4ood pushed a commit that referenced this pull request Oct 25, 2024
* fix: Synchronize EDR refresh (#1633)

* Failing test and added code to make it pass

* Created module for EdrLockSql and added statements

* alter test to check for correct response

* remove debug messages

* Introduce InMemoryEdrLock

* working version

* improve test for two different edrs.

* code dup

* refactor inmem acquireLock

* handle

* handle2

* refactor in mem EDR lock

* update EdrServiceImpl to enable force refresh

* Remove non existing job from verify.yaml

* Add ComponentTests

* fix failing uts

* Removes global lock in inmem variant

* inmem release lock should be atomic

* retrigger CI

* retrigger CI

* updates due to edc 0.10.0

* Trigger CI

* Trigger CI
@rafaelmag110 rafaelmag110 deleted the synchronize_edr_refresh branch December 16, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

4 participants