Skip to content

[Bug]: two commits created in one transaction fail the monotonic-commit trigger #413

Open

Description

@antoineatstariongroup

What type of issue is this?

  • Bug report
  • Feature request

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of the SysML2.NET
  • I have searched open and closed issues to ensure it has not already been reported

Description

commit.created defaults to now() (schema.generated.sql:297), which returns the transaction start time. Two commits created in one transaction get identical timestamps, and trg_commit_parent_monotonic (:354-379) rejects the parent edge between them as not strictly newer.

SysML2.NET.CodeGenerator.Tests/Sql/schema.concurrency.setup.sql:20 already stamps commits with clock_timestamp() for this reason; the schema default contradicts it, and any insert that omits created hits the problem.

Expected: a parent and child commit created in one transaction get distinct, increasing timestamps.

Fix:

  • Change the default to clock_timestamp(), or drop the default so the service must supply created.
  • Add the case to schema.smoke.sql.

Steps to Reproduce

BEGIN;
INSERT INTO sysml2.commit (id, project_id, model_version_id) VALUES (:c1, :p, 1), (:c2, :p, 1);
INSERT INTO sysml2.commit_parent (commit_id, parent_commit_id, ordinal) VALUES (:c2, :c1, 0);
-- ERROR: commit … is not strictly newer than its parent …

System Configuration

  • SysML2.NET version: PR [ADD] Sql schema #344 (feat/sql-schema-and-more, d5a90f2), SysML2.NET.CodeGenerator
  • Environment (Operating system, version and so on): Windows 11, PostgreSQL 17 (Docker)
  • .NET Framework version: .NET 10
  • Additional information: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CodeGenerationa Code Generation taskbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions