1

I have a pipe-like process that is made of micro services. Each service is responsible of reading files from an input folder, creating new files in an output folder and deleting the old ones.

Suppose I want to scale one of the services up, How do I avoid concurrency trouble?

user355289
  • 1,100
  • 2
  • 13
  • 23

1 Answers1

2

The service, which opens the file, should set Fileshare.None in order to avoid a second access.

Every service should check if the specific file is already opened by another service. See the following link: https://stackoverflow.com/a/937558/3193205

Alex
  • 31
  • 2
  • I tried this and it works, but my concerns are to the risk that a certain process may change the file share to None - then die unexpectedly and leave the file locked forever. – user355289 Jan 03 '18 at 08:08
  • If you use a using(...) statement the fileshare will be reset, even though a exception is thrown. – Alex Jan 08 '18 at 14:55