Skip to content

Failed export can cause data loss #3504

@samtstern

Description

@samtstern

[REQUIRED] Environment info

firebase-tools: all

Platform: all

[REQUIRED] Test case

In the export code for Firestore we delete all the existing export data before the new data is written:

rimraf.sync(firestorePath);

This can cause data loss if the export fails. It can also cause issues like #3487 where a clean shutdown puts the emulator in a bad state.

Instead we should:

  1. Export into a tmp directory
  2. If the export succeeds, overwrite the existing directory and delete the tmp data

[REQUIRED] Steps to reproduce

Hard to reproduce, but see above.

[REQUIRED] Expected behavior

Never lose data unless there is better data.

[REQUIRED] Actual behavior

See above.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions