Fix Cove run creation transaction scope
This commit is contained in:
parent
eff1cb3700
commit
2200b0cb00
@ -464,9 +464,6 @@ def _persist_datasource_objects(
|
|||||||
observed_at: datetime,
|
observed_at: datetime,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Create run_object_links for each active datasource found in the account stats."""
|
"""Create run_object_links for each active datasource found in the account stats."""
|
||||||
engine = db.get_engine()
|
|
||||||
|
|
||||||
with engine.begin() as conn:
|
|
||||||
for ds_prefix, ds_label in DATASOURCE_LABELS.items():
|
for ds_prefix, ds_label in DATASOURCE_LABELS.items():
|
||||||
status_key = f"{ds_prefix}F00"
|
status_key = f"{ds_prefix}F00"
|
||||||
status_code = flat.get(status_key)
|
status_code = flat.get(status_key)
|
||||||
@ -480,8 +477,9 @@ def _persist_datasource_objects(
|
|||||||
f"({status_code}); last session: {_fmt_utc(ds_last_ts)}"
|
f"({status_code}); last session: {_fmt_utc(ds_last_ts)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Upsert customer_objects
|
# Use the same SQLAlchemy session/transaction as JobRun creation.
|
||||||
customer_object_id = conn.execute(
|
# A separate engine connection cannot reliably see the uncommitted run row.
|
||||||
|
customer_object_id = db.session.execute(
|
||||||
text(
|
text(
|
||||||
"""
|
"""
|
||||||
INSERT INTO customer_objects (customer_id, object_name, object_type, first_seen_at, last_seen_at)
|
INSERT INTO customer_objects (customer_id, object_name, object_type, first_seen_at, last_seen_at)
|
||||||
@ -500,8 +498,7 @@ def _persist_datasource_objects(
|
|||||||
},
|
},
|
||||||
).scalar()
|
).scalar()
|
||||||
|
|
||||||
# Upsert job_object_links
|
db.session.execute(
|
||||||
conn.execute(
|
|
||||||
text(
|
text(
|
||||||
"""
|
"""
|
||||||
INSERT INTO job_object_links (job_id, customer_object_id, first_seen_at, last_seen_at)
|
INSERT INTO job_object_links (job_id, customer_object_id, first_seen_at, last_seen_at)
|
||||||
@ -513,8 +510,7 @@ def _persist_datasource_objects(
|
|||||||
{"job_id": job_id, "customer_object_id": customer_object_id},
|
{"job_id": job_id, "customer_object_id": customer_object_id},
|
||||||
)
|
)
|
||||||
|
|
||||||
# Upsert run_object_links
|
db.session.execute(
|
||||||
conn.execute(
|
|
||||||
text(
|
text(
|
||||||
"""
|
"""
|
||||||
INSERT INTO run_object_links (run_id, customer_object_id, status, error_message, observed_at)
|
INSERT INTO run_object_links (run_id, customer_object_id, status, error_message, observed_at)
|
||||||
|
|||||||
@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
This file documents all changes made to this project via Claude Code.
|
This file documents all changes made to this project via Claude Code.
|
||||||
|
|
||||||
|
## [2026-03-02]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Cove run creation after account linking/import:
|
||||||
|
- Fixed transaction scope in `app/cove_importer.py` for datasource object persistence.
|
||||||
|
- `run_object_links` / related upserts now use the same SQLAlchemy session transaction as `JobRun` creation instead of a separate engine connection.
|
||||||
|
- Prevents FK/visibility issues where a new uncommitted `JobRun` was not visible to a second connection, causing run creation to roll back and resulting in no Cove runs appearing.
|
||||||
|
|
||||||
## [2026-02-27]
|
## [2026-02-27]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user