Commit accdb09
authored
feat: make track deletes work across execution (#5517)
The track deletes features currently assume the entire dataset is being
fetched/saved within a single execution.
Which means it isn't compatible with checkpoints and fetching/saving
across multiple executions.
To solve this problem, this PR is introducing a way to explicitly define
the start and the end of the track deletes interval, storing the
starting point in a special checkpoint that survive across executions,
instead of assuming the start is always the beginning of the current
execution
cc @bastienbeurier to agree on the naming
`trackDeletesStart/trackDeletesEnd`
ex:
```
exec: async (nango) => {
await nango.trackDeletesStart('MyModel');
...
await nango.batchSave([...], 'MyModel');
...
const deleted = await nango.trackDeletesEnd('MyModel');
}
```
<!-- Summary by @propel-code-bot -->
---
The runner stores a per-model delete-window checkpoint keyed off the
sync checkpoint and, when the window closes, uses it to invoke deletion
of outdated records before clearing the checkpoint.
<details>
<summary><strong>Key Changes</strong></summary>
• Added `trackDeletesStart`/`trackDeletesEnd` to `NangoSyncBase` and
`NangoSyncRunner`, with per-model checkpoint keys and
`deleteOutdatedRecords` using stored `syncJobId`
• Refactored `Checkpointing` in
`packages/runner/lib/sdk/checkpointing.ts` to manage per-key state and
accept `key` arguments for checkpoint operations
• Expanded CLI parser/compiler validations to track `trackDeletes` calls
per model and enforce ordering around `batchSave`
• Updated docs and examples to use `trackDeletesStart`/`trackDeletesEnd`
and mark `deleteRecordsFromPreviousExecutions` as deprecated
• Reset behavior in `packages/shared/lib/clients/orchestrator.ts` now
hard-deletes all checkpoints with a key prefix
</details>
<details>
<summary><strong>Possible Issues</strong></summary>
• A run that calls `trackDeletesStart` but exits before
`trackDeletesEnd` will leave the delete-window checkpoint in place for
future runs
• The per-key `stateByKey` map in `Checkpointing` is not pruned, which
could grow in long-lived processes with many dynamic keys
• Full reset now returns an error if `hardDeleteCheckpoints` fails,
which could block user-initiated resets
</details>
---
*This summary was automatically generated by @propel-code-bot*1 parent ca4b279 commit accdb09
File tree
17 files changed
+396
-93
lines changed- docs
- implementation-guides/use-cases/syncs
- reference
- api/sync
- packages
- cli
- example/github/syncs
- lib
- services
- __snapshots__
- testMocks
- zeroYaml
- jobs/lib/execution
- runner-sdk
- lib
- runner/lib/sdk
17 files changed
+396
-93
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
Lines changed: 25 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 87 | + | |
92 | 88 | | |
93 | 89 | | |
94 | 90 | | |
95 | 91 | | |
96 | | - | |
97 | | - | |
| 92 | + | |
| 93 | + | |
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
| |||
103 | 99 | | |
104 | 100 | | |
105 | 101 | | |
106 | | - | |
107 | | - | |
108 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
109 | 105 | | |
110 | 106 | | |
111 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
112 | 111 | | |
113 | | - | |
114 | | - | |
| 112 | + | |
| 113 | + | |
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
118 | | - | |
| 117 | + | |
119 | 118 | | |
120 | 119 | | |
121 | | - | |
122 | | - | |
| 120 | + | |
| 121 | + | |
123 | 122 | | |
124 | 123 | | |
125 | 124 | | |
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
129 | | - | |
130 | | - | |
131 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
139 | | - | |
| 138 | + | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
152 | | - | |
| 150 | + | |
153 | 151 | | |
154 | | - | |
| 152 | + | |
155 | 153 | | |
156 | 154 | | |
157 | 155 | | |
| |||
160 | 158 | | |
161 | 159 | | |
162 | 160 | | |
163 | | - | |
| 161 | + | |
164 | 162 | | |
165 | 163 | | |
166 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | | - | |
44 | | - | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
172 | 175 | | |
173 | 176 | | |
174 | 177 | | |
175 | | - | |
| 178 | + | |
176 | 179 | | |
177 | 180 | | |
178 | 181 | | |
| |||
883 | 886 | | |
884 | 887 | | |
885 | 888 | | |
886 | | - | |
| 889 | + | |
887 | 890 | | |
888 | 891 | | |
889 | 892 | | |
890 | 893 | | |
891 | | - | |
| 894 | + | |
892 | 895 | | |
893 | 896 | | |
894 | 897 | | |
895 | 898 | | |
896 | 899 | | |
897 | | - | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
898 | 905 | | |
899 | 906 | | |
900 | | - | |
| 907 | + | |
901 | 908 | | |
902 | | - | |
| 909 | + | |
903 | 910 | | |
904 | 911 | | |
905 | 912 | | |
| |||
909 | 916 | | |
910 | 917 | | |
911 | 918 | | |
912 | | - | |
913 | | - | |
914 | | - | |
| 919 | + | |
| 920 | + | |
915 | 921 | | |
916 | 922 | | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
917 | 927 | | |
918 | 928 | | |
919 | 929 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | | - | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
477 | 480 | | |
| 481 | + | |
| 482 | + | |
478 | 483 | | |
479 | 484 | | |
480 | 485 | | |
| |||
0 commit comments