[PR #19651] [MERGED] 19644 Make atomic use correct database instead of default #15693

Closed
opened 2025-12-30 00:23:26 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19651
Author: @arthanson
Created: 6/5/2025
Status: Merged
Merged: 6/25/2025
Merged by: @jeremystretch

Base: mainHead: 19644-atomic-branching


📝 Commits (7)

  • 3cd0a93 19644 set atomic transactions to appropriate database
  • caaed88 19644 set atomic transactions for Job Script run
  • 78f1e7d 19644 set atomic transactions to appropriate database
  • 9e2248c 19644 set atomic transactions to appropriate database
  • ed9625d Merge branch 'main' into 19644-atomic-branching
  • 100f08d 19644 fix review comments
  • 3b4ca5e 19644 fix review comments

📊 Changes

11 files changed (+45 additions, -42 deletions)

View changed files

📝 netbox/circuits/views.py (+2 -2)
📝 netbox/dcim/utils.py (+2 -2)
📝 netbox/dcim/views.py (+3 -3)
📝 netbox/extras/jobs.py (+3 -0)
📝 netbox/ipam/api/views.py (+2 -2)
📝 netbox/netbox/api/viewsets/__init__.py (+3 -3)
📝 netbox/netbox/api/viewsets/mixins.py (+16 -16)
📝 netbox/netbox/views/generic/bulk_views.py (+7 -7)
📝 netbox/netbox/views/generic/feature_views.py (+2 -2)
📝 netbox/netbox/views/generic/object_views.py (+2 -2)
📝 netbox/virtualization/views.py (+3 -3)

📄 Description

Fixes: #19644

transaction.atomic will go to the default database, this is normally not a problem but if multiple schemas are databases are configured using a router (like with the branching plugin) this will be incorrect as the atomic wrapper should be done on the database the changes are made on.

In jobs.py the script running code is a special case as the script could potentially modify models in multiple schemas so both the default database needs a wrapper and any model specific ones - arbitrarily used device as the model to key off, but any ChangeLogged model could be used.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/19651 **Author:** [@arthanson](https://github.com/arthanson) **Created:** 6/5/2025 **Status:** ✅ Merged **Merged:** 6/25/2025 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `main` ← **Head:** `19644-atomic-branching` --- ### 📝 Commits (7) - [`3cd0a93`](https://github.com/netbox-community/netbox/commit/3cd0a930dcda09d933c2b9c7cfb4a8a32115b2fb) 19644 set atomic transactions to appropriate database - [`caaed88`](https://github.com/netbox-community/netbox/commit/caaed888f73c7e7342be3868d929a8c628c12c0c) 19644 set atomic transactions for Job Script run - [`78f1e7d`](https://github.com/netbox-community/netbox/commit/78f1e7d6180c0cec9fee471ce2e0cba9736d745c) 19644 set atomic transactions to appropriate database - [`9e2248c`](https://github.com/netbox-community/netbox/commit/9e2248cbf15dcf2ef2f42e12f20a3f2adfcdb4aa) 19644 set atomic transactions to appropriate database - [`ed9625d`](https://github.com/netbox-community/netbox/commit/ed9625d2dd70d464af04ff18210ac987be43d8ac) Merge branch 'main' into 19644-atomic-branching - [`100f08d`](https://github.com/netbox-community/netbox/commit/100f08d04d742d00f811ab69ef8ebbdfb6d3a403) 19644 fix review comments - [`3b4ca5e`](https://github.com/netbox-community/netbox/commit/3b4ca5ee482b0fcb33acd9cbd2bbfcb4c21fa790) 19644 fix review comments ### 📊 Changes **11 files changed** (+45 additions, -42 deletions) <details> <summary>View changed files</summary> 📝 `netbox/circuits/views.py` (+2 -2) 📝 `netbox/dcim/utils.py` (+2 -2) 📝 `netbox/dcim/views.py` (+3 -3) 📝 `netbox/extras/jobs.py` (+3 -0) 📝 `netbox/ipam/api/views.py` (+2 -2) 📝 `netbox/netbox/api/viewsets/__init__.py` (+3 -3) 📝 `netbox/netbox/api/viewsets/mixins.py` (+16 -16) 📝 `netbox/netbox/views/generic/bulk_views.py` (+7 -7) 📝 `netbox/netbox/views/generic/feature_views.py` (+2 -2) 📝 `netbox/netbox/views/generic/object_views.py` (+2 -2) 📝 `netbox/virtualization/views.py` (+3 -3) </details> ### 📄 Description ### Fixes: #19644 transaction.atomic will go to the default database, this is normally not a problem but if multiple schemas are databases are configured using a router (like with the branching plugin) this will be incorrect as the atomic wrapper should be done on the database the changes are made on. In jobs.py the script running code is a special case as the script could potentially modify models in multiple schemas so both the default database needs a wrapper and any model specific ones - arbitrarily used device as the model to key off, but any ChangeLogged model could be used. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:23:26 +01:00
adam closed this issue 2025-12-30 00:23:27 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15693