* perf(storage): cut batch-create round trips (import, bulk create, apply-batch)
A multi-issue create (import, bulk create, CreateIssuesWithFullOptions) ran
~20 SQL statements per issue, and its dependency pass ran a recursive cycle
CTE per edge over the union of both dependency tables, which Dolt cannot
index — every recursion step rescanned the edge tables, so an import whose
edges form chains went superlinear (400 issues: 73 s of 82 s in that CTE).
issueops batch create, same transaction and same stored outcome:
- createBatchCache: one IN-list read of every explicit id's presence in both
planes (replacing two COUNT probes per issue), one read of the batch's
stored labels (each issue's new labels then land in one multi-row INSERT),
created/label_added events buffered and written in one pass under the ids
InsertDerivedEvent would mint (same digest, same lowest free ordinal), and
runs of brand-new rows written with multi-row INSERTs (same ODKU clause)
then finished in order.
- Dependency pass: wisp routing and target presence from batch reads; the
cycle and hierarchy checks walk an in-memory copy of the edge tables,
loaded once and kept in step with every edge the pass writes (a pair it
already holds is re-read, since a clientFoundRows connection reports a
matched duplicate as written).
- createBlockedRecomputeIDs seeds all created edges and expands once.
Shared paths:
- Blocked-state recompute splits ids once per call by whether they own a
dependency row; edgeless ids (every freshly created issue) skip the two
union UPDATEs for one plain unmark, run after the chunk's union statements
on the first pass so the unions see what they saw before.
- appendChildrenInTx reads children per IN-list chunk, not per parent.
- ExecuteCreate hands its BatchContext to the batch body instead of having
it re-read the same config (-6 statements per apply-batch create item).
Not changed: one version-history row per created issue (the version
contract, version_history.go), journal order and content, and the per-row
bodies, which stay the path for singular creates.
Equivalence: internal/storage/createbatchequiv runs an import scenario
(upserts, duplicate ids, wisps, generated ids, cycles, hierarchy conflicts,
dangling/external targets, stale is_blocked, comments, journal and
versioned history on) through the fast and per-row bodies on the embedded
and server engines and compares every written table and the skip reports.
Re-pinned TestLargeBatchApplyStatementCounts*: embedded 7009/14014/846 ->
6396/12790/793, server 7008/14014/846 -> 6396/12791/793 (breakdown in
pinnedEmbeddedStatementCounts).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(storage): batch-create review fixes — lazy edge graph, opt-in recompute probe, insert budget
Review of the batch-create round-trip change (S1-S3 and nits):
- The dependency pass's in-memory graph no longer loads both edge tables.
It reads a node's outgoing edges through the issue_id index the first
time a walk reaches it: the batch's own endpoints up front, then one
IN-list read per BFS level. Memory and reads scale with the subgraph
the batch's walks touch, not the edge tables, so a two-edge create on a
large database no longer materialises every edge. A written edge whose
source was never loaded loads that source (row included).
- The blocked-state no-edge probe runs only when a create asks for it or
when a chunk holds at least 32 ids. Single-issue recomputes on close,
reopen, update and dependency edits issue exactly the statements they
did on main (the reopen sqlmock expectation is back to main's).
- Multi-row issue INSERTs are bounded by an estimated 16 MiB of bound
text as well as 100 rows. When a multi-row statement fails, its rows are
replayed one at a time, and the batch continues if every row lands
instead of returning the original error.
- Nits: document the binary-collation assumption behind Go string
equality; DisableCreateFastPathsForTest documents that it is
process-global and non-parallel, and panics on an overlapping caller;
drop the unreachable skip branch; explain why wisp targets need no
presence read.
Re-pinned TestLargeBatchApplyStatementCounts* classic 40: 793 -> 786
(the +7 probes on dep-add recomputes are gone; net vs main is -60, all of
it ExecuteCreate's config reuse). 356/712 unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(storage): search the batch dependency graph from both ends
The lazy per-node load (previous commit) still walked forward from the
check's start, so on a large stored graph a single create's cycle check
read every node reachable from its target — about 800 statements per
create on a 2000-issue fixture. The cycle and hierarchy questions a batch
asks almost always end at a row the batch just created, whose only
incoming edges are the batch's own.
depGraph now answers each reachability question with a bidirectional
search: forward from the start along outgoing edges (issue_id index),
backward from the goal along incoming edges (the three target-column
indexes, read as one UNION ALL per table), always expanding the smaller
frontier and loading a level's nodes in that direction once. The batch's
endpoints are loaded in both directions up front, so a create's checks
usually finish with no further read (a chain import, too: each new
edge's goal has no incoming edge yet). Rows are keyed by (table, source,
target), so a row read from both ends counts once. An incoming read
ignores a row whose matching column is not its first set target column,
as the CTE's COALESCE does. A written pair that neither loaded end can
vouch for is re-read instead of assumed new.
On a 50k-issue / 100k-edge database, a create with two blocks edges
now runs 27 statements, against the full-scan or per-node walks before
(numbers in the review-fix summary).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(storage): hold batch create to golden digests from the pre-change code
The batch-create equivalence test compared the fast paths with the same
code's per-row bodies, so changes the fast-path switch does not gate —
the recompute seed merge, the IN-list children read, ExecuteCreate's
context reuse, the prepare/finish split — were checked only by older
contract tests. Its batch was also too small to cross a chunk boundary
and never set RejectStaleUpserts.
createbatchequiv now runs four scenarios, each through the fast and
per-row bodies, and checks both against a per-table row count and
SHA-256 recorded from ebe3b6bcb (before the fast paths existed;
CREATEBATCHEQUIV_GOLDEN_DIR re-records them):
- small: the original scenario;
- import458 and import458-reject-stale: the review's 458-issue batch
(every chunk boundary, wisps and cross-plane edges, cycles, hierarchy
conflicts, duplicate ids across deferred runs, generated and
hierarchical ids, stale upserts rejected and accepted), plus new edges
whose blocked-state fallout reaches stored rows outside the batch (a
spawner's waiter, an upserted parent's existing child);
- apply: an apply-batch through ExecuteCreate, dep adds and an update.
The recorded digests match on the embedded and server engines (the
server test now sets the fixture's prefix, so generated ids agree).
Dropping the spawner-waiter seeding is invisible to the fast-vs-per-row
comparison and caught by the golden check.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(storage): large-graph create benchmark
batchbench measures creates against a database already holding a large
dependency graph (batchfixtures.LargeGraphInserts: N issues, ~2N
acyclic edges with wide reachable sets and a deep parent-child forest,
committed as a Dolt version): ExecuteCreate under an existing parent with
an existing blocker, a store create with two blocks edges, and an
apply-batch of creates each with a parent-child and a blocks dep_add.
It logs wall time, statements and Go allocation per shape on the
embedded and server engines. Opt in with BEADS_BENCH_LARGE_GRAPH=<issues>
(and BEADS_BENCH_LARGE_GRAPH_CREATES); it asserts nothing.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* perf(storage): read incoming dependency edges one target column at a time
The bidirectional graph search read a node's incoming edges with one
UNION ALL over the three target columns per table. Dolt plans that as a
scan: 0.7 s per read on a 100k-edge table, where each leg alone is a 1 ms
lookup on its own index (EXPLAIN shows IndexedTableAccess per leg). Issue
the three legs as separate reads into one row set; a row matched through
two columns still counts once.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(storage): run the 458-issue equivalence scenarios outside the race lane
The 458-issue golden scenarios took the embedded tier's shard over its
20-minute limit under -race (the in-process engine's own instrumentation;
about 35 s each without it). They move to
TestCreateBatchFastPathsMatchPerRowLarge_Embedded, skipped under -race and
added to nightly.yml's non-race embedded step, following the precedent of
the 712-item statement-count and 1000-item wall-clock cases. The light
scenarios (small, apply) stay in TestCreateBatchFastPathsMatchPerRow_Embedded
on every lane. The server backend (built without -race in its full
suite) runs both: TestCreateBatchFastPathsMatchPerRow_Dolt and, as its own
top-level test so the shard manifest's hash places it on another shard
(about four minutes there), TestCreateBatchFastPathsMatchPerRowLarge_Dolt.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
284 lines
12 KiB
Go
284 lines
12 KiB
Go
package issueops
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"database/sql/driver"
|
|
"errors"
|
|
"fmt"
|
|
"regexp"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/DATA-DOG/go-sqlmock"
|
|
|
|
"github.com/steveyegge/beads/internal/storage/rowid"
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
// TestFlushAuxEventsMintsThePerRowIDs pins that the buffered events flush
|
|
// assigns each row the id InsertDerivedEvent would have: the lowest ordinal of
|
|
// its digest not already held by a same-content row — counting rows already
|
|
// stored and rows minted earlier in the same flush — while a different-content
|
|
// row with the same issue and second is not counted.
|
|
func TestFlushAuxEventsMintsThePerRowIDs(t *testing.T) {
|
|
ctx := context.Background()
|
|
db, mock, tx := beginMockTx(t)
|
|
defer db.Close()
|
|
|
|
const at = "2026-01-02 03:04:05"
|
|
created := normalizeAuxEvent("events", AuxEvent{
|
|
IssueID: "bd-1", EventType: types.EventCreated, Actor: "importer",
|
|
OldValue: str(""), NewValue: str(""), CreatedAt: at,
|
|
})
|
|
label := normalizeAuxEvent("events", AuxEvent{
|
|
IssueID: "bd-1", EventType: types.EventLabelAdded, Actor: "importer",
|
|
Comment: str("Added label: x"), CreatedAt: at,
|
|
})
|
|
createdDigest, labelDigest := auxEventDigest(created), auxEventDigest(label)
|
|
storedCreated := rowid.New("events", 0, createdDigest)
|
|
|
|
mock.ExpectQuery(regexp.QuoteMeta("FROM events")).
|
|
WithArgs("bd-1", at).
|
|
WillReturnRows(sqlmock.NewRows([]string{"id", "issue_id", "event_type", "actor", "old_value", "new_value", "comment", "created_at"}).
|
|
// A stored same-content created row holds ordinal 0.
|
|
AddRow(storedCreated, "bd-1", string(types.EventCreated), "importer", "", "", nil, at).
|
|
// Same issue and second, different content: not counted.
|
|
AddRow("legacy-random-id", "bd-1", string(types.EventLabelAdded), "importer", nil, nil, "Added label: y", at))
|
|
mock.ExpectExec(regexp.QuoteMeta("INSERT INTO events")).
|
|
WithArgs(
|
|
rowid.New("events", 1, createdDigest), "bd-1", string(types.EventCreated), "importer", str(""), str(""), sql.NullString{}, at,
|
|
rowid.New("events", 2, createdDigest), "bd-1", string(types.EventCreated), "importer", str(""), str(""), sql.NullString{}, at,
|
|
rowid.New("events", 0, labelDigest), "bd-1", string(types.EventLabelAdded), "importer", sql.NullString{}, sql.NullString{}, str("Added label: x"), at,
|
|
).
|
|
WillReturnResult(sqlmock.NewResult(0, 3))
|
|
|
|
cache := &createBatchCache{}
|
|
cache.bufferEvent("events", created)
|
|
cache.bufferEvent("events", created)
|
|
cache.bufferEvent("events", label)
|
|
if err := cache.flushEvents(ctx, tx); err != nil {
|
|
t.Fatalf("flushEvents: %v", err)
|
|
}
|
|
if err := mock.ExpectationsWereMet(); err != nil {
|
|
t.Fatalf("unmet expectations: %v", err)
|
|
}
|
|
}
|
|
|
|
// TestDepBatchGraphTracksTheStoredRows pins the graph's bookkeeping across the
|
|
// dependency pass's inserts: an unseen pair is added with the inserted type
|
|
// without a read; a pair it already holds is re-read, because a matched
|
|
// duplicate (which keeps the stored type) and a real insert both report
|
|
// RowsAffected 1 on a clientFoundRows connection.
|
|
func TestDepBatchGraphTracksTheStoredRows(t *testing.T) {
|
|
ctx := context.Background()
|
|
db, mock, tx := beginMockTx(t)
|
|
defer db.Close()
|
|
|
|
l := &depBatchLookups{graph: newDepGraph()}
|
|
for _, id := range []string{"bd-a", "bd-b", "bd-c"} {
|
|
l.graph.loadedOut[id] = true
|
|
l.graph.loadedIn[id] = true
|
|
}
|
|
l.graph.add(depEdgeKey{table: "dependencies", source: "bd-b", target: "bd-a"}, types.DepRelated)
|
|
reaches := func(from, to string, parentsOnly bool) bool {
|
|
t.Helper()
|
|
ok, err := l.graph.reaches(ctx, tx, from, to, parentsOnly)
|
|
if err != nil {
|
|
t.Fatalf("reaches: %v", err)
|
|
}
|
|
return ok
|
|
}
|
|
|
|
// New pair: no read, and the scheduling walk sees it at once.
|
|
if err := l.recordInsert(ctx, tx, "dependencies", &types.Dependency{IssueID: "bd-c", DependsOnID: "bd-b", Type: types.DepBlocks}, 1); err != nil {
|
|
t.Fatalf("recordInsert(new): %v", err)
|
|
}
|
|
if !reaches("bd-c", "bd-b", false) {
|
|
t.Fatal("new blocks edge not walkable")
|
|
}
|
|
// Known pair reported as written: re-read; the stored row kept "related".
|
|
mock.ExpectQuery(regexp.QuoteMeta("SELECT type FROM dependencies WHERE issue_id = ? AND "+DepTargetExpr+" = ?")).
|
|
WithArgs("bd-b", "bd-a").
|
|
WillReturnRows(sqlmock.NewRows([]string{"type"}).AddRow(string(types.DepRelated)))
|
|
if err := l.recordInsert(ctx, tx, "dependencies", &types.Dependency{IssueID: "bd-b", DependsOnID: "bd-a", Type: types.DepParentChild}, 1); err != nil {
|
|
t.Fatalf("recordInsert(known): %v", err)
|
|
}
|
|
if reaches("bd-b", "bd-a", true) || reaches("bd-c", "bd-a", false) {
|
|
t.Fatal("a matched duplicate must not add the incoming type's edge")
|
|
}
|
|
// Nothing written: nothing changes, nothing is read.
|
|
if err := l.recordInsert(ctx, tx, "dependencies", &types.Dependency{IssueID: "bd-a", DependsOnID: "bd-c", Type: types.DepBlocks}, 0); err != nil {
|
|
t.Fatalf("recordInsert(noop): %v", err)
|
|
}
|
|
if reaches("bd-a", "bd-c", false) {
|
|
t.Fatal("an unwritten edge must not be walkable")
|
|
}
|
|
if err := mock.ExpectationsWereMet(); err != nil {
|
|
t.Fatalf("unmet expectations: %v", err)
|
|
}
|
|
}
|
|
|
|
// TestIssueInsertChunksHonorsRowsAndBytes pins the multi-row INSERT budget:
|
|
// at most issueInsertRowsPerStatement rows, a new statement before the
|
|
// estimated bytes would pass issueInsertBytesPerStatement, and an oversized
|
|
// row still travels (alone) rather than being dropped.
|
|
func TestIssueInsertChunksHonorsRowsAndBytes(t *testing.T) {
|
|
small := func(n int) []*types.Issue {
|
|
out := make([]*types.Issue, n)
|
|
for i := range out {
|
|
out[i] = &types.Issue{ID: fmt.Sprintf("bd-%d", i), Title: "t"}
|
|
}
|
|
return out
|
|
}
|
|
sizes := func(chunks [][]*types.Issue) []int {
|
|
var out []int
|
|
for _, c := range chunks {
|
|
out = append(out, len(c))
|
|
}
|
|
return out
|
|
}
|
|
if got := sizes(issueInsertChunks(small(250))); fmt.Sprint(got) != "[100 100 50]" {
|
|
t.Fatalf("250 small rows chunked as %v, want [100 100 50]", got)
|
|
}
|
|
big := strings.Repeat("x", 10<<20)
|
|
huge := strings.Repeat("y", 20<<20)
|
|
issues := []*types.Issue{
|
|
{ID: "bd-a", Description: big},
|
|
{ID: "bd-b", Notes: big},
|
|
{ID: "bd-c", Title: "small"},
|
|
{ID: "bd-d", Description: huge},
|
|
{ID: "bd-e", Title: "small"},
|
|
}
|
|
if got := sizes(issueInsertChunks(issues)); fmt.Sprint(got) != "[1 2 1 1]" {
|
|
t.Fatalf("long-text rows chunked as %v, want [1 2 1 1]", got)
|
|
}
|
|
}
|
|
|
|
// TestInsertIssueRowsReplaysAFailedStatement pins the multi-row INSERT's
|
|
// failure handling: the rows of a refused statement are written one at a
|
|
// time, the batch continues when every row lands, and the first row that
|
|
// cannot land fails it with the per-row path's error.
|
|
func TestInsertIssueRowsReplaysAFailedStatement(t *testing.T) {
|
|
issues := []*types.Issue{{ID: "bd-1", Title: "one"}, {ID: "bd-2", Title: "two"}}
|
|
multi := regexp.QuoteMeta("INSERT INTO issues")
|
|
t.Run("replay succeeds", func(t *testing.T) {
|
|
db, mock, tx := beginMockTx(t)
|
|
defer db.Close()
|
|
mock.ExpectExec(multi).WillReturnError(errors.New("packet too large"))
|
|
mock.ExpectExec(multi).WithArgs(issueRowArgMatchers("bd-1")...).WillReturnResult(sqlmock.NewResult(0, 1))
|
|
mock.ExpectExec(multi).WithArgs(issueRowArgMatchers("bd-2")...).WillReturnResult(sqlmock.NewResult(0, 1))
|
|
if err := insertIssueRowsIntoTable(context.Background(), tx, "issues", issues, false); err != nil {
|
|
t.Fatalf("insertIssueRowsIntoTable = %v, want nil after a clean replay", err)
|
|
}
|
|
if err := mock.ExpectationsWereMet(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
})
|
|
t.Run("replay fails", func(t *testing.T) {
|
|
db, mock, tx := beginMockTx(t)
|
|
defer db.Close()
|
|
mock.ExpectExec(multi).WillReturnError(errors.New("packet too large"))
|
|
mock.ExpectExec(multi).WithArgs(issueRowArgMatchers("bd-1")...).WillReturnResult(sqlmock.NewResult(0, 1))
|
|
mock.ExpectExec(multi).WithArgs(issueRowArgMatchers("bd-2")...).WillReturnError(errors.New("data too long"))
|
|
err := insertIssueRowsIntoTable(context.Background(), tx, "issues", issues, false)
|
|
if err == nil || !strings.Contains(err.Error(), "failed to insert issue bd-2") || !strings.Contains(err.Error(), "data too long") {
|
|
t.Fatalf("insertIssueRowsIntoTable = %v, want the per-row error for bd-2", err)
|
|
}
|
|
})
|
|
}
|
|
|
|
// issueRowArgMatchers matches one single-row issue INSERT whose id is id.
|
|
func issueRowArgMatchers(id string) []driver.Value {
|
|
args := make([]driver.Value, len(issueInsertArgs(&types.Issue{})))
|
|
for i := range args {
|
|
args[i] = sqlmock.AnyArg()
|
|
}
|
|
args[0] = id
|
|
return args
|
|
}
|
|
|
|
// TestDepGraphSearchesFromBothEnds pins the lazy, bidirectional search: each
|
|
// step expands the smaller frontier, loading only that level's unloaded nodes
|
|
// in that direction (outgoing through issue_id, incoming through the three
|
|
// target columns), never the whole edge tables and never a node twice; an
|
|
// incoming read ignores a row matched through a column that is not its
|
|
// target; and a write whose pair the graph cannot vouch for is re-read
|
|
// rather than guessed.
|
|
func TestDepGraphSearchesFromBothEnds(t *testing.T) {
|
|
ctx := context.Background()
|
|
db, mock, tx := beginMockTx(t)
|
|
defer db.Close()
|
|
type row = [3]string
|
|
expect := func(incoming bool, ids []string, rows map[string][]row) {
|
|
args := make([]driver.Value, len(ids))
|
|
for i, id := range ids {
|
|
args[i] = id
|
|
}
|
|
for _, table := range []string{"dependencies", "wisp_dependencies"} {
|
|
cols := []string{"issue_id"}
|
|
if incoming {
|
|
cols = []string{"depends_on_issue_id", "depends_on_wisp_id", "depends_on_external"}
|
|
}
|
|
for i, col := range cols {
|
|
r := sqlmock.NewRows([]string{"issue_id", "target", "type"})
|
|
if i == 0 {
|
|
for _, x := range rows[table] {
|
|
r.AddRow(x[0], x[1], x[2])
|
|
}
|
|
}
|
|
q := "SELECT issue_id, " + DepTargetExpr + ", type FROM " + table + " WHERE " + col + " IN ("
|
|
mock.ExpectQuery(regexp.QuoteMeta(q)).WithArgs(args...).WillReturnRows(r)
|
|
}
|
|
}
|
|
}
|
|
g := newDepGraph()
|
|
// Stored: a -> b (blocks), b -> c (parent-child), w -> a (wisp table,
|
|
// blocks). Is a reachable from c? (No.) Is c reachable from w? (Yes.)
|
|
// Step 1, frontiers {c} and {a} tie: forward from c, which has no edges.
|
|
expect(false, []string{"c"}, nil)
|
|
if ok, err := g.reaches(ctx, tx, "c", "a", false); err != nil || ok {
|
|
t.Fatalf("reaches(c, a) = %v, %v; want false, nil", ok, err)
|
|
}
|
|
// Forward from w: w -> a; then backward from c (smaller? tie: forward
|
|
// again from {a}): a -> b; then {b} vs {c}: forward b -> c meets c.
|
|
expect(false, []string{"w"}, map[string][]row{"wisp_dependencies": {{"w", "a", "blocks"}}})
|
|
expect(false, []string{"a"}, map[string][]row{"dependencies": {{"a", "b", "blocks"}}})
|
|
expect(false, []string{"b"}, map[string][]row{"dependencies": {{"b", "c", "parent-child"}}})
|
|
if ok, err := g.reaches(ctx, tx, "w", "c", false); err != nil || !ok {
|
|
t.Fatalf("reaches(w, c) = %v, %v; want true, nil", ok, err)
|
|
}
|
|
// Backward: once the forward frontier {x, y} outgrows the backward one,
|
|
// the search keeps reading incoming rows — c, b, a, w — and never loads
|
|
// x or y. A row matched through a non-target column is ignored, and rows
|
|
// already known (b -> c, a -> b, w -> a) are not counted again.
|
|
g.loadedOut["s"] = true
|
|
g.add(depEdgeKey{table: "dependencies", source: "s", target: "x"}, types.DepBlocks)
|
|
g.add(depEdgeKey{table: "dependencies", source: "s", target: "y"}, types.DepBlocks)
|
|
expect(true, []string{"c"}, map[string][]row{"dependencies": {{"b", "c", "parent-child"}, {"q", "elsewhere", "blocks"}}})
|
|
expect(true, []string{"b"}, map[string][]row{"dependencies": {{"a", "b", "blocks"}}})
|
|
expect(true, []string{"a"}, map[string][]row{"wisp_dependencies": {{"w", "a", "blocks"}}})
|
|
expect(true, []string{"w"}, nil)
|
|
if ok, err := g.reaches(ctx, tx, "s", "c", false); err != nil || ok {
|
|
t.Fatalf("reaches(s, c) = %v, %v; want false, nil", ok, err)
|
|
}
|
|
if _, known := g.rows[depEdgeKey{table: "dependencies", source: "q", target: "elsewhere"}]; known {
|
|
t.Fatal("a row matched through a non-target column was taken as an incoming edge")
|
|
}
|
|
if n := g.out.parents["b"]["c"]; n != 1 {
|
|
t.Fatalf("edge b -> c counted %d times after being read from both ends, want 1", n)
|
|
}
|
|
// A written pair neither end vouches for is re-read, not assumed new.
|
|
l := &depBatchLookups{graph: g}
|
|
mock.ExpectQuery(regexp.QuoteMeta("SELECT type FROM dependencies WHERE issue_id = ? AND "+DepTargetExpr+" = ?")).
|
|
WithArgs("m", "n").WillReturnRows(sqlmock.NewRows([]string{"type"}).AddRow("related"))
|
|
if err := l.recordInsert(ctx, tx, "dependencies", &types.Dependency{IssueID: "m", DependsOnID: "n", Type: types.DepBlocks}, 1); err != nil {
|
|
t.Fatalf("recordInsert: %v", err)
|
|
}
|
|
if g.out.sched["m"]["n"] != 0 {
|
|
t.Fatal("a matched duplicate's incoming type was taken as the stored one")
|
|
}
|
|
if err := mock.ExpectationsWereMet(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|