Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

fix: Prevent blocking of the whole manager while cloning a vfolder #539

Conversation

vesselofgod
Copy link
Contributor

resolved : lablup/backend.ai#354

prevent blocking of the whole manager while cloning a vfolder

  • Run the clone operation as a background task and just return the bgtask ID in the vfolder clone API, so that clients could keep track of the progress and result.
    clone pr

  • Split the destination vfolder creation and actual clone operations, and insert the database transaction to create the destination vfolder record between them.
    split

@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #539 (34b2415) into main (e99f515) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #539   +/-   ##
=======================================
  Coverage   48.87%   48.87%           
=======================================
  Files          54       54           
  Lines        9025     9025           
=======================================
  Hits         4411     4411           
  Misses       4614     4614           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e99f515...34b2415. Read the comment docs.

@vesselofgod vesselofgod self-assigned this Feb 18, 2022
user_uuid = str(user_uuid)
group_uuid = None
ownership_type = 'user'
insert_values = {
'id': folder_id.hex,
'id': uuid.uuid4().hex,
Copy link
Member

Choose a reason for hiding this comment

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

Where is the original folder ID?
What happens if the folder ID is lost?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the good point! I thought that UUID and folder_id would always be the same. But, it was actually different and found that other tasks of vfolder had errors. so, I will fix it.

@@ -25,6 +25,7 @@
from aiohttp import web
import aiohttp_cors
import sqlalchemy as sa
from ..background import ProgressReporter
Copy link
Member

Choose a reason for hiding this comment

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

Please reorder the import following other imports.
(What is the rule?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I reorder it in alphabetical order?

Copy link
Member

Choose a reason for hiding this comment

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

Try out finding by yourself. How are the current imports organized?

changes/539.fix Outdated
@@ -0,0 +1 @@
Split the destination vfolder creation and actual clone operationsrun the clone operation as a background task and just return the bgtask ID in the vfolder clone API, so that clients could keep track of the progress and result
Copy link
Member

Choose a reason for hiding this comment

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

Please fix typos and try to write it shorter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got it!

src/ai/backend/manager/api/vfolder.py Outdated Show resolved Hide resolved
changes/539.fix Outdated Show resolved Hide resolved
@achimnol
Copy link
Member

Just a note for myself.
Need to refactor: move the following lines in api.vfolder.create() and api.vfolder.clone() to SharedConfig:
image

@achimnol
Copy link
Member

The PR itself also needs to split the txn block. Currently the storage proxy RPC call has race condition with the target vfolder creation.

…e RPC calls

* TODO: update storage-proxy to allow creation of destination vfolder with exist_ok=True option.
  (for backward compatibility)
@achimnol achimnol added this to the 21.03 milestone Feb 28, 2022
@achimnol achimnol merged commit aa580cc into main Mar 2, 2022
@achimnol achimnol deleted the fix/prevent-blocking-of-the-whole-manager-while-cloning-a-vfolder branch March 2, 2022 08:05
achimnol added a commit that referenced this pull request Mar 2, 2022
)

* Change the vfolder clone operation to run as a background task
* Add `bgtask_id` in the response of vfolder clone API

Co-authored-by: Joongi Kim <[email protected]>
Backported-From: main (22.03)
Backported-To: 21.09
achimnol added a commit that referenced this pull request Mar 2, 2022
)

* Change the vfolder clone operation to run as a background task
* Add `bgtask_id` in the response of vfolder clone API

Co-authored-by: Joongi Kim <[email protected]>
Backported-From: main (22.03)
Backported-To: 21.03
@achimnol achimnol changed the title Fix/prevent blocking of the whole manager while cloning a vfolder fix: Prevent blocking of the whole manager while cloning a vfolder Mar 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent blocking of the whole manager while cloning a vfolder
2 participants