fix: rebuilds collect under one lock and keep moved lastmods

A rebuild takes the transaction-scoped advisory lock
golem15.sitemap.rebuild before it reads the settings and collects, and
applies in the same transaction, so a second rebuild collects only after
the first has committed. apply no longer writes the lastmod of a content
row it did not create, so a lastmod RecordSaved moved meanwhile stays.
This commit is contained in:
Jakub Zych
2026-11-04 23:04:01 +01:00
parent f58d55555c
commit 2200e46d98
4 changed files with 209 additions and 28 deletions

View File

@@ -16,16 +16,34 @@ const filterPluginID = "acme.filter"
// fakeFilter excludes addresses containing "noindex" (reason noindex) and
// puts addresses containing "promo" into the group offers. It records the
// batches it was asked.
// batches it was asked; hook, when set, runs at the start of every Decide
// (a test blocks a rebuild there).
type fakeFilter struct {
mu sync.Mutex
batches [][]contract.Candidate
hook func()
}
// setHook sets the Decide hook for one test.
func (f *fakeFilter) setHook(t interface{ Cleanup(func()) }, fn func()) {
f.mu.Lock()
f.hook = fn
f.mu.Unlock()
t.Cleanup(func() {
f.mu.Lock()
f.hook = nil
f.mu.Unlock()
})
}
func (f *fakeFilter) Decide(_ context.Context, batch []contract.Candidate) ([]contract.Decision, error) {
f.mu.Lock()
f.batches = append(f.batches, append([]contract.Candidate(nil), batch...))
hook := f.hook
f.mu.Unlock()
if hook != nil {
hook()
}
out := make([]contract.Decision, len(batch))
for i, c := range batch {
switch {