Concurrent Read/Writes to tensorflow::*File across different processes
@p3achyjr,
Could you please provide more context/information or the complete standalone code to reproduce the issue which helps to analyse the issue in an effective way. Thank you! ```
// p1.cc
#include "tensorflow/core/lib/io/record_writer.h"
#include "tensorflow/core/example/example.pb.h"

int main(int argc, char** argv) {
  std::unique_ptr<tensorflow::WritableFile> file;
  TF_CHECK_OK(tensorflow::Env::Default()->NewWritableFile("/tmp/file.tfrecord", &file));

  RecordWriter writer(file.get());
  for (int i = 0; i < 1000000; ++i) {
    tensorflow::Example example;
    auto& features = *example.mutable_features()->mutable_feature();
    features["key"].mutable_int64_list()->add_value(i);
   
    std::string data;
    example.SerializeToString(&data);
    TF_CHECK_OK(writer.WriteRecord(data));
  }
  TF_CHECK_OK(writer.Close());
  TF_CHECK_OK(file->Close());

  return 0;
}
```

```
// p2.cc
#include "tensorflow/core/lib/io/record_reader.h"

int main(int argc, char** argv) {
  std::unique_ptr<tensorflow::RandomAccessFile> file;
  TF_CHECK_OK(tensorflow::Env::Default()->NewRandomAccessFile("/tmp/file.tfrecord", &file));

  SequentialRecordReader reader(file.get());
  for (int i = 0; i < 1000000; ++i) {
    tstring record;
    reader.ReadRecord(&record);
    // Not sure how to parse in C++, but this loop should be able to complete.
  }

  return 0;
}
```

```
// BUILD
cc_binary(
  name = "p1"
  srcs = ["p1.cc"]
  deps = [<path_to_tensorflow_shlib>]
  # deps = ["@org_tensorflow//tensorflow:libtensorflow_cc"]
)

cc_binary(
  name = "p2"
  srcs = ["p2.cc"]
  deps = [<path_to_tensorflow_shlib>]
  # deps = ["@org_tensorflow//tensorflow:libtensorflow_cc"]
)
```

```
// run.sh
bazel build //:p1
bazel build //:p2
./bazel-bin/p1
./bazel-bin/p2
```

 let me know if you need anything else :)
 Fwiw I'm still not sure whether tensorflow protects concurrent read/writes within its API, but concurrent read/writes in general are not synchronized :)
<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Support

### Have you reproduced the bug with TF nightly?

No

### Source

source

### Tensorflow Version

2.11

### Custom Code

Yes

### OS Platform and Distribution

Debian GNU/Linux 10

### Mobile device

_No response_

### Python version

3.8

### Bazel version

6.1.1

### GCC/Compiler version

9

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current Behaviour?

Are `tensorflow::WritableFile` and `tensorflow::RandomAccessFile` safe to read/write across multiple processes? If not, how can we ensure that they are?

If there are tensorflow file locking primitives, that would be ideal :)

If not, being able to grab the file descriptor from the TF file object should be sufficient--can we do this?

### Standalone code to reproduce the issue

```shell
# Process 1.

int main(int argc, char** argv) {
  std::unique_ptr<tensorflow::WritableFile> file;
  TF_CHECK_OK(tensorflow::Env::Default()->NewWritableFile(filename, &file));

  RecordWriter writer(file.get());
  writer.WriteRecord("hahaha");
  TF_CHECK_OK(writer.Close());
  TF_CHECK_OK(file->Close());

  return 0;
}

# Process 2.
int main(int argc, char** argv) {
  std::unique_ptr<tensorflow::RandomAccessFile> file;
  TF_CHECK_OK(tensorflow::Env::Default()->NewRandomAccessFile(*f, &file));

  SequentialRecordReader reader(file.get());
  tstring record;
  reader.ReadRecord(&record);

  return 0;
}
```


### Relevant log output

_No response_</details>