0

Scenario:

  • Two clients on different machines read a range of cells from a shared workbook (.../drive/{drive-id}/items/{id}/workbook/worksheets/{id|name}/range(address='...').
  • If they both don't find the row that they are looking for, they attempt to add a new row to the end of the table.
  • If this happens at the same time, both clients might see that row 37 is the end of the table, and they will both attempt to write to row 38, thus one of the new rows may be lost or corrupted.

I suspect this is a common issue (perhaps with other types of files in Sharepoint/Onedrive too), so I was wondering if there is any standardized mechanism within the /workbook APIs (or elsewhere in MS Graph?) to help with synchronization of multiple clients?

I've not actually tried to prove that the above scenario is possible, but I'm not even using sessions when writing to the workbook, and I'm actually writing to one cell at a time, so it's easy to believe that the new row will contain a mix of data from both clients (ie corruption). I could switch to writing the entire row at once, possibly within a session, but it's still safe to assume that one of the two write operations from the two clients will be overwritten.

I suppose I should use the classic "try to create a .lock file next to the xlsx, and if that fails, wait and try again". Is this what people do? Or maybe I should switch from Excel to SQL .

Thanks

kostasvs
  • 391
  • 4
  • 12
  • Checkout in case if you're responsible for synchronization then consider this... first check whether the above excel service supports change notification or [delta query](https://learn.microsoft.com/en-us/graph/delta-query-overview) while using Microsoft Graph API - Delta query. It enables applications to discover newly created, updated, or deleted entities without performing a full read of the target resource with every request. Microsoft Graph applications can use delta query to efficiently synchronize changes with a local data store. – Dev Jun 19 '21 at 19:24
  • Thanks @Dev. When I used the phrase "synchronization of multiple clients", I think I gave the wrong impression. I'm looking for some kind of file locking mechanism, within the /workbook api perhaps, or within /drive, or, who knows. Something to stop multiple apps reading/writing corrupted/incomplete data to a file at the same time. The equivalent of a mutex if you prefer. – kostasvs Jun 21 '21 at 18:56
  • 1
    Thanks for the clarification @kostasvs. AFAIK its not available one. Being said that you can file [Graph API user voice](https://techcommunity.microsoft.com/t5/microsoft-365-developer-platform/idb-p/Microsoft365DeveloperPlatform) so that it can be considered to be implemented by MS. – Dev Jun 22 '21 at 15:22

0 Answers0