feat: snapshot retained client reconciliation state
This commit is contained in:
@@ -299,8 +299,10 @@ func (store *Store) CleanupTerminal(ctx context.Context, issueUUID domain.UUID,
|
||||
defer tx.Rollback()
|
||||
var hash []byte
|
||||
var terminal int
|
||||
var revision uint64
|
||||
var phase uint32
|
||||
var totalCharged uint64
|
||||
err = tx.QueryRowContext(ctx, `SELECT immutable_sha256, terminal, total_charged_bytes FROM commands WHERE issue_uuid = ?`, issueUUID[:]).Scan(&hash, &terminal, &totalCharged)
|
||||
err = tx.QueryRowContext(ctx, `SELECT immutable_sha256, command_revision, phase, terminal, total_charged_bytes FROM commands WHERE issue_uuid = ?`, issueUUID[:]).Scan(&hash, &revision, &phase, &terminal, &totalCharged)
|
||||
if err == sql.ErrNoRows {
|
||||
return ErrUnknownCommand
|
||||
}
|
||||
@@ -324,7 +326,7 @@ func (store *Store) CleanupTerminal(ctx context.Context, issueUUID domain.UUID,
|
||||
if totalCharged > clientTotal {
|
||||
return fmt.Errorf("client spool aggregate charge counter mismatch")
|
||||
}
|
||||
if _, err := tx.ExecContext(ctx, `INSERT INTO command_tombstones(issue_uuid, immutable_sha256, acknowledged_at) VALUES (?, ?, ?)`, issueUUID[:], hash, acknowledgedAt.UnixNano()); err != nil {
|
||||
if _, err := tx.ExecContext(ctx, `INSERT INTO command_tombstones(issue_uuid, immutable_sha256, command_revision, terminal_lifecycle, acknowledged_at) VALUES (?, ?, ?, ?, ?)`, issueUUID[:], hash, revision, phase, acknowledgedAt.UnixNano()); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := tx.ExecContext(ctx, `DELETE FROM commands WHERE issue_uuid = ?`, issueUUID[:]); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user