appscope icon indicating copy to clipboard operation
appscope copied to clipboard

When multiple processes write to an event/metric file, that file can become corrupted easily

Open seanvaleo opened this issue 3 years ago • 2 comments

We have seen this when scoping applications like apt, that create multiple child processes. The events.json, metrics.json files can become mangled.

In a container:

apt update
scope run -- apt install -y python3 nginx firefox
scope events -a

seanvaleo avatar Mar 04 '22 21:03 seanvaleo

There are are a number of possible approaches here:

  1. Do nothing. Suggest that using the cli to write to files is not ideal because of the issue described here, and that the workaround is to use tcp or unix destinations instead.
  2. Switch the CLI to configure scoped processes to sent their data to the cli over tcp or unix transports. Then the cli can write received data to a file in a way that prevents corruption.
  3. Use SCOPE_PID to configure the library to write to files with pid-specific names. The cli would need to be improved to look for an arbitrary number of files with this approach.

jrcheli avatar Mar 16 '22 20:03 jrcheli

3 looks like the easiest and most robust approach. We would need to modify the CLI to read in multiple event and metric files relating to one session. Tagging this as a CLI task.

seanvaleo avatar Nov 21 '22 16:11 seanvaleo