Skip to content

Some assignments are lost on update #25

@le-jeu

Description

@le-jeu

Describe the bug
On update, assignments that are already synced before are dropped by the server.

To Reproduce
Steps to reproduce the behavior:

  1. Create an draw, sync and add a team
  2. Create two task, assign one
  3. Update
  4. Assign the other task
  5. Update
  6. Open WebUI to see the result
  7. Repeat (5) and see only one (alternating) task with an assignment

Related lines

{"assignments", `CREATE TABLE assignments (opID char(40) NOT NULL, taskID char(40) NOT NULL, gid char(21) NOT NULL, KEY opID (opID), KEY gid (gid), CONSTRAINT fk_assignments_gid FOREIGN KEY (gid) REFERENCES agent (gid) ON DELETE CASCADE, CONSTRAINT fk_assignments_opid FOREIGN KEY (opID) REFERENCES operation (ID) ON DELETE CASCADE, KEY taskID (taskID,opID), CONSTRAINT fk_assignments_taskid FOREIGN KEY (taskID,opID) REFERENCES task (ID, opID) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;`},

CREATE TABLE assignments (
  opID char(40) NOT NULL, 
  taskID char(40) NOT NULL, 
  gid char(21) NOT NULL, 
  KEY opID (opID), 
  KEY gid (gid), 
  CONSTRAINT fk_assignments_gid FOREIGN KEY (gid) REFERENCES agent (gid) ON DELETE CASCADE, 
  CONSTRAINT fk_assignments_opid FOREIGN KEY (opID) REFERENCES operation (ID) ON DELETE CASCADE, 
  KEY taskID (taskID,opID),
  CONSTRAINT fk_assignments_taskid FOREIGN KEY (taskID,opID) REFERENCES task (ID, opID) ON DELETE CASCADE
);

_, err := tx.Exec("REPLACE INTO task (ID, opID, comment, taskorder, state, zone, delta) VALUES (?, ?, ?, ?, ?, ?, ?)", // REPLACE OK SCB

I suspect we get the correct list here:

b, err := t.GetAssignments(tx)

so, already synced assignments are not "replaced", but the data is deleted following the cascade deletion due to the REPLACE INTO query.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions