Spaces:
Running
Running
Commit ·
e4f56e2
1
Parent(s): fc5a6ca
fix: optimize SQLite write performance and re-enable WAL mode to resolve database locking
Browse filesFiles changed (2)
71 unmodified lines727374757677787980818283848586878825 unmodified lines11411511611711811912012 unmodified lines13313413513613713871 unmodified lines|| deletedNodeIds.Contains(e.ToNodeId)).ToList();// 2. Perform deletes sequentially to satisfy SQLite FK constraintsif (edgesToDelete.Any()){_context.Edges.RemoveRange(edgesToDelete);await _context.SaveChangesAsync();}if (nodesToDelete.Any()){_context.TaskNodes.RemoveRange(nodesToDelete);await _context.SaveChangesAsync();}// 3. Update or Create Nodes25 unmodified lines// 4. Update or Create Edgesforeach (var edge in incomingEdges){// Only create edge if it wasn't deleted in step 2 (i.e. not connected to a deleted node)if (deletedNodeIds.Contains(edge.FromNodeId) || deletedNodeIds.Contains(edge.ToNodeId)){continue;12 unmodified lines}}await _context.SaveChangesAsync();return true;}71 unmodified lines72737475767778798081828384858625 unmodified lines11211311411511611711812 unmodified lines13113213313413513613771 unmodified lines|| deletedNodeIds.Contains(e.ToNodeId)).ToList();// 2. Queue deletes (but don't save yet)if (edgesToDelete.Any()){_context.Edges.RemoveRange(edgesToDelete);}if (nodesToDelete.Any()){_context.TaskNodes.RemoveRange(nodesToDelete);}// 3. Update or Create Nodes25 unmodified lines// 4. Update or Create Edgesforeach (var edge in incomingEdges){// Only create edge if it wasn't deleted (i.e. not connected to a deleted node)if (deletedNodeIds.Contains(edge.FromNodeId) || deletedNodeIds.Contains(edge.ToNodeId)){continue;12 unmodified lines}}// 5. Single atomic save to minimize lock durationawait _context.SaveChangesAsync();return true;}
15 unmodified lines1617181920212215 unmodified linesbuilder.Services.AddDbContext<AppDbContext>(options =>{var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");options.UseSqlite(connectionString);});// --- Repositories (Infrastructure) ---15 unmodified lines1617181920212215 unmodified linesbuilder.Services.AddDbContext<AppDbContext>(options =>{var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");options.UseSqlite(connectionString, o => o.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery));});// --- Repositories (Infrastructure) ---
FlowAPI.Infrastructure/Repositories/GraphRepository.cs+3-4
FlowAPI/Program.cs+1-1