Stdlib_unix: improve error message when failing to load stored_data
This MR aims to improve the error message when the store fails to load it's Stored_data.t. Such error may occur when the file permissions are wrong or when files are missing/corrupted.
This was particularly embarrassing when some user are running/importing/upgrading snapshots/nodes with different rights, without noticing it, resulting in the obscure error below.
Before:
ct 03 15:47:02.733: the store is in an inconsistent state:
Oct 03 15:47:02.733: Error:
Oct 03 15:47:02.733: Failed to load on-disk data: no corresponding data found in file /tmp/lapin/store/chain_NetXdQprcVkpa/status.
Oct 03 15:47:02.733:
Oct 03 15:47:02.733: attempting to restore the store's consistency...
Oct 03 15:47:02.750: the consistency of the floating stores was restored
octez-node: Error:
Failed to load on-disk data: no corresponding data found in file /tmp/lapin/store/chain_NetXdQprcVkpa/status.
Now:
- when wrong permission
Oct 03 16:21:08.416: the store is in an inconsistent state:
Oct 03 16:21:08.416: Error:
Oct 03 16:21:08.416: Failed to load on-disk data from /tmp/lapin/store/chain_NetXdQprcVkpa/status: in open "/tmp/lapin/store/chain_NetXdQprcVkpa/status": Permission denied.
Oct 03 16:21:08.416:
Oct 03 16:21:08.416: attempting to restore the store's consistency...
Oct 03 16:21:08.430: the consistency of the floating stores was restored
octez-node: Error:
Failed to load on-disk data from /tmp/lapin/store/chain_NetXdQprcVkpa/status: in open "/tmp/lapin/store/chain_NetXdQprcVkpa/status": Permission denied.
- when corrupted file
Oct 03 16:22:11.579: the store is in an inconsistent state:
Oct 03 16:22:11.579: Error:
Oct 03 16:22:11.579: Failed to load on-disk data from /tmp/lapin/store/chain_NetXdQprcVkpa/status: Data_encoding.Read_error(Not enough data).
Oct 03 16:22:11.579:
Oct 03 16:22:11.579: attempting to restore the store's consistency...
Oct 03 16:22:11.587: the consistency of the floating stores was restored
octez-node: Error:
Failed to load on-disk data from /tmp/lapin/store/chain_NetXdQprcVkpa/status: Data_encoding.Read_error(Not enough data).
Manually testing the MR
Create a data dir in sandbox. Alter the /tmp/lapin/store/chain_NetXdQprcVkpa/status file by:
- changing it's rights
- breaking it's data
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR
Edited by Victor Allombert