Commit 37810d9
authored
fix(collections): rehydrate in-process collections lazily after init failure (#468)
When NewInProcessBackend boots, it iterates every on-disk collection and
calls newVectorEngine to construct its engine wrapper. For the postgres
engine that constructor performs a "test embedding" probe that requires
the embedding model to be reachable. If the embedding service is briefly
unavailable at boot — e.g. the node hosting the embedding model has
temporary NATS connectivity issues — the construction fails and the
collection is silently dropped from the in-memory map. Subsequent
operations against that collection (Upload / Search / ListEntries / …)
all return "collection not found" indefinitely, even after the embedding
service comes back, because nothing ever retries.
Worse, the collection still exists on disk (its JSON sidecar) and its
data still exists in the vector DB (e.g. the per-collection
documents_col_<uuid> table in PostgreSQL). From the user's perspective
their collection has silently disappeared.
Two changes:
1. NewInProcessBackend always registers every on-disk collection in
state.Collections — even when newVectorEngine returns nil. A nil
entry is a placeholder meaning "known on disk, not yet loaded".
2. backendInProcess.lookup centralises the cache read for every
operation. If the cache holds a placeholder, it retries
newVectorEngine now, under the write lock. So as soon as the
embedding service is reachable again, the next request to the
collection will rehydrate it transparently. If init still fails or
the collection isn't on disk at all, lookup returns (nil, false)
and the operation surfaces "collection not found" as before.
The state.EnsureCollection callback used by the internal RAG provider
already handled the placeholder case (it re-inits whenever the cache
entry is missing or nil), so it needs no change.
This does not address the underlying probe-and-cache pattern in
LocalRecall's NewPersistentPostgresCollection — read-only operations
on existing collections still require an embedding probe at engine
construction. That is a separate, deeper fix worth pursuing in
LocalRecall directly.1 parent c1a1231 commit 37810d9
1 file changed
Lines changed: 53 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
66 | 99 | | |
67 | 100 | | |
68 | 101 | | |
| |||
80 | 113 | | |
81 | 114 | | |
82 | 115 | | |
83 | | - | |
84 | | - | |
85 | | - | |
| 116 | + | |
86 | 117 | | |
87 | 118 | | |
88 | 119 | | |
| |||
108 | 139 | | |
109 | 140 | | |
110 | 141 | | |
111 | | - | |
112 | | - | |
113 | | - | |
| 142 | + | |
114 | 143 | | |
115 | 144 | | |
116 | 145 | | |
117 | 146 | | |
118 | 147 | | |
119 | 148 | | |
120 | 149 | | |
121 | | - | |
122 | | - | |
123 | | - | |
| 150 | + | |
124 | 151 | | |
125 | 152 | | |
126 | 153 | | |
127 | 154 | | |
128 | 155 | | |
129 | 156 | | |
130 | 157 | | |
131 | | - | |
132 | | - | |
133 | | - | |
| 158 | + | |
134 | 159 | | |
135 | 160 | | |
136 | 161 | | |
| |||
159 | 184 | | |
160 | 185 | | |
161 | 186 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 187 | + | |
168 | 188 | | |
169 | 189 | | |
170 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
171 | 194 | | |
172 | 195 | | |
173 | 196 | | |
174 | 197 | | |
175 | | - | |
176 | | - | |
177 | | - | |
| 198 | + | |
178 | 199 | | |
179 | 200 | | |
180 | 201 | | |
| |||
186 | 207 | | |
187 | 208 | | |
188 | 209 | | |
189 | | - | |
190 | | - | |
191 | | - | |
| 210 | + | |
192 | 211 | | |
193 | 212 | | |
194 | 213 | | |
| |||
201 | 220 | | |
202 | 221 | | |
203 | 222 | | |
204 | | - | |
205 | | - | |
206 | | - | |
| 223 | + | |
207 | 224 | | |
208 | 225 | | |
209 | 226 | | |
| |||
220 | 237 | | |
221 | 238 | | |
222 | 239 | | |
223 | | - | |
224 | | - | |
225 | | - | |
| 240 | + | |
226 | 241 | | |
227 | 242 | | |
228 | 243 | | |
229 | 244 | | |
230 | 245 | | |
231 | 246 | | |
232 | 247 | | |
233 | | - | |
234 | | - | |
235 | | - | |
| 248 | + | |
236 | 249 | | |
237 | 250 | | |
238 | 251 | | |
| |||
257 | 270 | | |
258 | 271 | | |
259 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
260 | 280 | | |
261 | | - | |
262 | 281 | | |
263 | 282 | | |
264 | 283 | | |
| |||
0 commit comments