Commit fdf816f
authored
fix(storage): defer blob deletes for cache-unknown blobs until dedupe rebuild completes (#4195)
With dedupe enabled on cloud storage, duplicate blobs are stored as
zero-size placeholders whose content lives in a single original blob,
resolvable only through the dedupe cache. When the cache is lost or
incomplete (e.g. an ephemeral local cache database with cloud storage),
deleteBlob's cache lookup misses, the move-content-to-next-duplicate
logic is skipped entirely, and the storage delete destroys the only
content-bearing copy. Every duplicate of that digest in other
repositories is then permanently broken (416 RequestedRangeNotSatisfiable
on read), which is the data loss reported in issue #2625.
The startup dedupe/restore walk (RunDedupeBlobs) already rebuilds the
cache from storage, but GC/retention can run before or while it does,
which is exactly the corruption window.
Fix: track completion of the dedupe/restore walk on the ImageStore
(reusing the DedupeTaskGenerator completion callback, renamed to
OnRunComplete and now fired for both dedupe and restore runs) and
defer deletes of content-bearing blobs that the cache cannot account
for until the walk has completed. Such deletes
return the new ErrDedupeRebuildInProgress; GC/retention retries on a
later interval, and blobs known to the cache (or zero-size
placeholders) are unaffected. Local storage is exempt: it dedupes via
hardlinks, so deleting one path never destroys shared content.
The gate is armed only when RunDedupeBlobs is invoked (the server
always does at startup), so stores that never schedule the walk keep
existing behavior. Generator submission order in StartBackgroundTasks
is deliberately unchanged: the walk being scheduled a few statements
after the GC generator leaves only a sub-millisecond arming window,
whereas reordering the submissions shifts the GC generator's first
pass by a scheduler slot and changes long-standing GC timing behavior.
Fixes #2625
Signed-off-by: Johnathan Aretos <johnathan@squareup.com>1 parent 8ceb7f3 commit fdf816f
5 files changed
Lines changed: 519 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
918 | 918 | | |
919 | 919 | | |
920 | 920 | | |
921 | | - | |
| 921 | + | |
922 | 922 | | |
923 | | - | |
| 923 | + | |
924 | 924 | | |
925 | 925 | | |
926 | 926 | | |
| |||
943 | 943 | | |
944 | 944 | | |
945 | 945 | | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
950 | 952 | | |
951 | 953 | | |
952 | 954 | | |
| |||
975 | 977 | | |
976 | 978 | | |
977 | 979 | | |
978 | | - | |
| 980 | + | |
979 | 981 | | |
980 | 982 | | |
981 | 983 | | |
| |||
985 | 987 | | |
986 | 988 | | |
987 | 989 | | |
988 | | - | |
| 990 | + | |
989 | 991 | | |
990 | 992 | | |
991 | 993 | | |
992 | | - | |
| 994 | + | |
993 | 995 | | |
994 | 996 | | |
995 | 997 | | |
| |||
1044 | 1046 | | |
1045 | 1047 | | |
1046 | 1048 | | |
1047 | | - | |
| 1049 | + | |
1048 | 1050 | | |
1049 | 1051 | | |
1050 | | - | |
| 1052 | + | |
1051 | 1053 | | |
1052 | 1054 | | |
1053 | 1055 | | |
| |||
1074 | 1076 | | |
1075 | 1077 | | |
1076 | 1078 | | |
1077 | | - | |
| 1079 | + | |
1078 | 1080 | | |
1079 | 1081 | | |
1080 | | - | |
| 1082 | + | |
1081 | 1083 | | |
1082 | 1084 | | |
1083 | 1085 | | |
| |||
1095 | 1097 | | |
1096 | 1098 | | |
1097 | 1099 | | |
1098 | | - | |
| 1100 | + | |
1099 | 1101 | | |
1100 | 1102 | | |
1101 | 1103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | | - | |
| 627 | + | |
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
| |||
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
665 | | - | |
| 665 | + | |
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
| |||
687 | 687 | | |
688 | 688 | | |
689 | 689 | | |
690 | | - | |
| 690 | + | |
691 | 691 | | |
692 | 692 | | |
693 | 693 | | |
694 | | - | |
| 694 | + | |
695 | 695 | | |
696 | 696 | | |
697 | 697 | | |
| |||
703 | 703 | | |
704 | 704 | | |
705 | 705 | | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
706 | 776 | | |
707 | 777 | | |
708 | 778 | | |
| |||
741 | 811 | | |
742 | 812 | | |
743 | 813 | | |
744 | | - | |
| 814 | + | |
745 | 815 | | |
746 | 816 | | |
747 | 817 | | |
| |||
760 | 830 | | |
761 | 831 | | |
762 | 832 | | |
763 | | - | |
| 833 | + | |
764 | 834 | | |
765 | 835 | | |
766 | 836 | | |
767 | | - | |
| 837 | + | |
768 | 838 | | |
769 | 839 | | |
770 | 840 | | |
771 | 841 | | |
772 | 842 | | |
773 | 843 | | |
774 | | - | |
| 844 | + | |
775 | 845 | | |
776 | 846 | | |
777 | 847 | | |
778 | 848 | | |
779 | 849 | | |
780 | 850 | | |
781 | 851 | | |
782 | | - | |
| 852 | + | |
783 | 853 | | |
784 | 854 | | |
785 | 855 | | |
| |||
816 | 886 | | |
817 | 887 | | |
818 | 888 | | |
819 | | - | |
| 889 | + | |
820 | 890 | | |
821 | 891 | | |
822 | 892 | | |
| |||
836 | 906 | | |
837 | 907 | | |
838 | 908 | | |
839 | | - | |
| 909 | + | |
840 | 910 | | |
841 | 911 | | |
842 | 912 | | |
843 | | - | |
| 913 | + | |
844 | 914 | | |
845 | 915 | | |
846 | 916 | | |
847 | 917 | | |
848 | 918 | | |
849 | 919 | | |
850 | | - | |
| 920 | + | |
851 | 921 | | |
852 | 922 | | |
853 | 923 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
| |||
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
98 | 105 | | |
99 | 106 | | |
100 | 107 | | |
| |||
1983 | 1990 | | |
1984 | 1991 | | |
1985 | 1992 | | |
1986 | | - | |
| 1993 | + | |
1987 | 1994 | | |
1988 | 1995 | | |
1989 | 1996 | | |
| |||
2009 | 2016 | | |
2010 | 2017 | | |
2011 | 2018 | | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
2012 | 2029 | | |
2013 | 2030 | | |
2014 | 2031 | | |
| |||
2056 | 2073 | | |
2057 | 2074 | | |
2058 | 2075 | | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
2059 | 2085 | | |
2060 | 2086 | | |
2061 | 2087 | | |
| |||
2442 | 2468 | | |
2443 | 2469 | | |
2444 | 2470 | | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
2445 | 2477 | | |
2446 | 2478 | | |
2447 | 2479 | | |
| |||
2470 | 2502 | | |
2471 | 2503 | | |
2472 | 2504 | | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
2473 | 2508 | | |
2474 | 2509 | | |
2475 | 2510 | | |
| |||
2490 | 2525 | | |
2491 | 2526 | | |
2492 | 2527 | | |
2493 | | - | |
2494 | | - | |
2495 | | - | |
2496 | | - | |
2497 | | - | |
2498 | | - | |
2499 | | - | |
2500 | | - | |
2501 | | - | |
2502 | | - | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
2503 | 2543 | | |
2504 | 2544 | | |
2505 | 2545 | | |
| |||
0 commit comments