Skip to content

Database locked errors during iosxe_interface_ethernet parallel creation with source_templates #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
coffmant opened this issue Dec 13, 2024 · 12 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@coffmant
Copy link

IOS-XE 17.9.5

We are using a for_each loop to create iosxe_interface_ethernet interfaces en masse. Each port is using an iosxe_template to supply the interface parameters.

The first creation succeeds. Other creates that are running in parallel fail with this lock error.

Error: Client Error

with iosxe_interface_ethernet.ports["4/0/32"],
on iosxe_interface_ethernet.ports.tf line 1, in resource "iosxe_interface_ethernet" "ports":
1: resource "iosxe_interface_ethernet" "ports" {

Failed to configure object (PATCH), got error: HTTP Request failed:
StatusCode 409, RESTCONF errors {Error:[{ErrorType:application
ErrorTag:lock-denied ErrorAppTag:
ErrorPath:/Cisco-IOS-XE-native:native/interface/GigabitEthernet
ErrorMessage:the configuration database is locked by session 18
yang_mgmt_infra tcp (system from 127.0.0.1) on since 2024-12-13 17:52:56
IOS-XE YANG Infrastructure ErrorInfo:}]} {PatchId: GlobalStatus:{Ok:false Errors:{Error:[]}} EditStatus:{Edit:[]} Errors:{Error:[]}}

@coffmant
Copy link
Author

#show netconf-yang datastores
Datastore Name : running
Partial Lock ID : 61
Partially Locked By Session : 18
Partially Locked Time : 2024-12-16T21:18:47+00:00
Selected XPATHs : /native
Locked Nodes : /native

#clear netconf-yang session 18
% Error: Session 18 is internal, can't be killed

What exactly is going on with this session 18?

@danischm
Copy link
Member

Unfortunately, the RESTCONF implementation on XE returns a success response while the database is still locked. Therefore we have to rely on a retry mechanism. I assume it is eventually able to apply the configuration after running "terraform apply" again. If that is the case, the provider configuration has an attribute to change the number of retries, so you can try increasing it accordingly.

@danischm danischm added the question Further information is requested label Jan 11, 2025
@coffmant
Copy link
Author

This works if I retry 30-40 times. It takes 40 minutes for the stack to converge. This is not a useable workaround. Is there an upstream bug I can follow? If not, there needs to be one.

@danischm
Copy link
Member

So you are saying, if you increase the number of retries to 30-40 via the provider configuration, you are able to apply the full configuration in a single run ("terraform apply"), but it takes 40 min to complete?

I am not aware of an upstream bug, but feel free to open a case with TAC and add me to the case.

@coffmant
Copy link
Author

coffmant commented Mar 4, 2025

Yes, it depends on the number of changes to be applied but on average, it completes around 2-3 changes each attempt and the rest fail. So if I increase the retries and play with the timeout values, I can get it to "complete" an apply. Obviously, this is completely unworkable.

@danischm
Copy link
Member

danischm commented Mar 4, 2025

If you are saying it is only able to apply 2-3 changes, that is a bit surprising as I have been able to apply this (https://github.com/netascode/terraform-iosxe-evpn-example) config to four C9000v without any issues (134 resources in total) and without tuning any of the mentioned parameters. Which devices are you targeting?

@coffmant
Copy link
Author

You may be missing the nuance that this is occuring when we make use of iosxe_template. I was able to do huge apply's when I'm not using the template. I had to use template because that was the only way we could specify some parameters in that version.

@danischm
Copy link
Member

Thank you, this was the missing link.

@danischm
Copy link
Member

516f7f8

@danischm danischm reopened this Apr 24, 2025
@danischm danischm added the enhancement New feature or request label Apr 24, 2025
@danischm danischm self-assigned this Apr 24, 2025
@danischm
Copy link
Member

The issue is related to the fact that certain config changes (e.g., applying a template to an interface) trigger a sync operation which locks the configuration database for a significant amount of time. Newer versions of XE might provider better results/performance. I have added an enhancement on the provider side that waits and blocks further operations for specific resources (ie. iosxe_interface_ethernet) until the database lock has been released. This enhancement has been added in the recent v0.5.10 release.

@coffmant
Copy link
Author

Tested with a batch of 12 ports on the latest provider release. Same result if I let it fail. Most of them

iosxe_interface_ethernet.ports["2/0/13"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F13, 2m30s elapsed]
iosxe_interface_ethernet.ports["2/0/19"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F19, 2m30s elapsed]
iosxe_interface_ethernet.ports["2/0/16"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F16, 2m30s elapsed]
iosxe_interface_ethernet.ports["2/0/14"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F14, 2m30s elapsed]
iosxe_interface_ethernet.ports["2/0/10"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F10, 1m20s elapsed]
iosxe_interface_ethernet.ports["2/0/2"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F2, 2m10s elapsed]
iosxe_interface_ethernet.ports["2/0/11"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F11, 2m40s elapsed]
iosxe_interface_ethernet.ports["2/0/3"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F3, 2m40s elapsed]
iosxe_interface_ethernet.ports["2/0/13"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F13, 2m40s elapsed]
iosxe_interface_ethernet.ports["2/0/19"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F19, 2m40s elapsed]
iosxe_interface_ethernet.ports["2/0/16"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F16, 2m40s elapsed]
iosxe_interface_ethernet.ports["2/0/14"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F14, 2m40s elapsed]
iosxe_interface_ethernet.ports["2/0/10"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F10, 1m30s elapsed]
iosxe_interface_ethernet.ports["2/0/2"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F2, 2m20s elapsed]
iosxe_interface_ethernet.ports["2/0/11"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F11, 2m50s elapsed]
iosxe_interface_ethernet.ports["2/0/3"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F3, 2m50s elapsed]
iosxe_interface_ethernet.ports["2/0/13"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F13, 2m50s elapsed]
iosxe_interface_ethernet.ports["2/0/19"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F19, 2m50s elapsed]
iosxe_interface_ethernet.ports["2/0/16"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F16, 2m50s elapsed]
iosxe_interface_ethernet.ports["2/0/14"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F14, 2m50s elapsed]
iosxe_interface_ethernet.ports["2/0/10"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F10, 1m40s elapsed]
iosxe_interface_ethernet.ports["2/0/2"]: Still modifying... [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F2, 2m30s elapsed]
iosxe_interface_ethernet.ports["2/0/11"]: Modifications complete after 3m0s [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F11]
iosxe_interface_ethernet.ports["2/0/13"]: Modifications complete after 3m0s [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F13]
iosxe_interface_ethernet.ports["2/0/3"]: Modifications complete after 3m0s [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F3]
iosxe_interface_ethernet.ports["2/0/19"]: Modifications complete after 3m0s [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F19]
iosxe_interface_ethernet.ports["2/0/14"]: Modifications complete after 3m0s [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F14]
iosxe_interface_ethernet.ports["2/0/16"]: Modifications complete after 3m0s [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F16]
iosxe_interface_ethernet.ports["2/0/10"]: Modifications complete after 1m48s [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F10]
iosxe_interface_ethernet.ports["2/0/2"]: Modifications complete after 2m34s [id=Cisco-IOS-XE-native:native/interface/GigabitEthernet=2%2F0%2F2]

│ Warning: Applied changes may be incomplete

│ The plan was created with the -target option in effect, so some changes
│ requested in the configuration may have been ignored and the output values
│ may not be fully updated. Run the following command to verify that no other
│ changes are pending:
│ tofu plan

│ Note that the -target option is not suitable for routine use, and is
│ provided only for exceptional situations such as recovering from errors or
│ mistakes, or when OpenTofu specifically suggests to use it as part of an
│ error message.


│ Error: Client Error

│ with iosxe_interface_ethernet.ports["2/0/18"],
│ on iosxe_interface_ethernet.ports.tf line 1, in resource "iosxe_interface_ethernet" "ports":
│ 1: resource "iosxe_interface_ethernet" "ports" {

│ Failed to configure object (PATCH), got error: HTTP Request failed:
│ StatusCode 409, RESTCONF errors {Error:[{ErrorType:application
│ ErrorTag:lock-denied ErrorAppTag:
│ ErrorPath:/Cisco-IOS-XE-native:native/interface/GigabitEthernet
│ ErrorMessage:the configuration database is locked by session 18
│ yang_mgmt_infra tcp (system from 127.0.0.1) on since 2024-12-17 19:16:24
│ IOS-XE YANG Infrastructure ErrorInfo:}]} {PatchId: GlobalStatus:{Ok:false Errors:{Error:[]}} EditStatus:{Edit:[]} Errors:{Error:[]}}


│ Error: Client Error

│ with iosxe_interface_ethernet.ports["2/0/17"],
│ on iosxe_interface_ethernet.ports.tf line 1, in resource "iosxe_interface_ethernet" "ports":
│ 1: resource "iosxe_interface_ethernet" "ports" {

│ Failed to configure object (PATCH), got error: HTTP Request failed:
│ StatusCode 409, RESTCONF errors {Error:[{ErrorType:application
│ ErrorTag:lock-denied ErrorAppTag:
│ ErrorPath:/Cisco-IOS-XE-native:native/interface/GigabitEthernet
│ ErrorMessage:the configuration database is locked by session 18
│ yang_mgmt_infra tcp (system from 127.0.0.1) on since 2024-12-17 19:16:24
│ IOS-XE YANG Infrastructure ErrorInfo:}]} {PatchId: GlobalStatus:{Ok:false Errors:{Error:[]}} EditStatus:{Edit:[]} Errors:{Error:[]}}


│ Error: Client Error

│ with iosxe_interface_ethernet.ports["2/0/15"],
│ on iosxe_interface_ethernet.ports.tf line 1, in resource "iosxe_interface_ethernet" "ports":
│ 1: resource "iosxe_interface_ethernet" "ports" {

│ Failed to delete object, got error: HTTP Request failed: StatusCode 409,
│ RESTCONF errors {Error:[{ErrorType:application ErrorTag:lock-denied
│ ErrorAppTag: ErrorPath: ErrorMessage:the configuration database is locked
│ by session 18 yang_mgmt_infra tcp (system from 127.0.0.1) on since
│ 2024-12-17 19:16:24
│ IOS-XE YANG Infrastructure ErrorInfo:}]} {PatchId: GlobalStatus:{Ok:false Errors:{Error:[]}} EditStatus:{Edit:[]} Errors:{Error:[]}}


│ Error: Client Error

│ with iosxe_interface_ethernet.ports["2/0/12"],
│ on iosxe_interface_ethernet.ports.tf line 1, in resource "iosxe_interface_ethernet" "ports":
│ 1: resource "iosxe_interface_ethernet" "ports" {

│ Failed to delete object, got error: HTTP Request failed: StatusCode 409,
│ RESTCONF errors {Error:[{ErrorType:application ErrorTag:lock-denied
│ ErrorAppTag: ErrorPath: ErrorMessage:the configuration database is locked
│ by session 18 yang_mgmt_infra tcp (system from 127.0.0.1) on since
│ 2024-12-17 19:16:24
│ IOS-XE YANG Infrastructure ErrorInfo:}]} {PatchId: GlobalStatus:{Ok:false Errors:{Error:[]}} EditStatus:{Edit:[]} Errors:{Error:[]}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants