Forum Discussion

RajanKhorasiya's avatar
RajanKhorasiya
Explorer | Level 3
6 years ago

MoveV2Async throws error too_many_write_operations

it throws exception while moving files using parallel.foreach functionality in c#

HERE My request

await dbx.Files.MoveV2Async("/rootfolder/filename", "rootfolder/movedfile/filename")

dbx is my dropbox client

can you Share code with me using .net sdk for moving files parallel manner.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    The MoveV2Async method is the right way to move an existing file or folder, so it looks like you already have the right idea. It sounds like you're getting the 'too_many_write_operations' error though.

    The 'too_many_write_operations' error indicates "lock contention". That's result of how Dropbox works on the backend. This is a technical inability to make a modification in the account or shared folder at the time of the API call. This error indicates that there was simultaneous activity in the account or shared folder preventing your app from making the state-modifying call (e.g., adding, editing, moving, or deleting files/folders) it is attempting. The simultaneous activity could be coming from your app itself, or elsewhere, e.g., from the user's desktop client. It can come from the same user, or another member of a shared folder. You can find more information about lock contention here:

    https://www.dropbox.com/developers/reference/data-ingress-guide

    In short, to avoid this error, you should avoid making multiple concurrent state modifications. E.g., don't issue multiple such requests at a time, and use batch endpoints whenever possible. That won't guarantee that you won't run in to this error though, as contention can still come from other sources, so you may also want to implement automatic retries in your app.

     

    • RajanKhorasiya's avatar
      RajanKhorasiya
      Explorer | Level 3

      I tried batch Moved as well but that's also not working for me . Suppose I have 20 files in one folder and i try to move that folder to another with files it's moving but out of 20 only 13 files moved and other seven not remain in that folder so i am asking for any way or method that can help me to move entire folder as fast as possible and give me some code as well for moving 20 files from one folder to another it's request.

      (2)so are you saying that i can't move file parallel in c#?

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        If you want to move individual files or folders, using MoveV2Async is the right way to do so. In that case though, if you have multiple to move, you would do need to do so serially, as calling MoveV2Async multiple times in parallel will likely cause lock contention.

        If you want to move multiple items at one time, it's better to use one call to MoveBatchV2Async instead. That will allow you to move multiple items at once without causing lock contention with yourself. It is still possible for this to hit lock contention with other activity in the account though, so you do still need to implement error handling around this.

        It sounds like you already tried that, so if it's not working as expected, please share the relevant code and error you're getting.