You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nexus holds on to specific service backends of crdb and crucible-pantry for too long #3763
While testing service failover on rack2, I noticed that nexus held on to the same cockroachdb backend without attempting to use any of the other nodes in the 5-node database cluster, causing requests to fail until the one it favored came back.
The same happened with pantry requests for disk import blocks / bulk writes. I haven't got to the point of seeing the TTL being exhausted. I tried waiting for up to 5 minutes and the request still couldn't succeed until the pantry zone Nexus has been using prior to its outage came up again.
Our API to interface with CockroachDB from Nexus involves "constructing a URL", and right now, we embed a single point-in-time address of CockroachDB into this URL.
We should probably avoid doing this, and embed the service name into the URL, so it actually use DNS during later lookups.
Understood. The current behavior, in conjunction with #3613, results in an 1 in 15 probability that a user will not be able to use the system at all. I happened to be in this situation when my workstation always used the one nexus that had the first CRDB backend I brought down to test failover. :(
The same happened with pantry requests for disk import blocks / bulk writes. I haven't got to the point of seeing the TTL being exhausted. I tried waiting for up to 5 minutes and the request still couldn't succeed until the pantry zone Nexus has been using prior to its outage came up again.
In this case, there's no TTL: a specific pantry from the list of available ones is selected once and used for a disk until that disk is finalized.
One thing that could be done is to check of the selected pantry is still responsive and choose another one if not, but it was important not keep as much code out of the import chunk hot-path as possible, as any checks there will be multiplied by the number of chunks to import and slow down imports. That being said, slow imports are better than non-working imports :) I'll give this some thought.
Sorry for not being clear in pantry's case. I understand the need to stay with the same pantry for the same disk snapshot. But the issue I ran into is with new/separate snapshot requests still holding on to the unresponsive one.
changed the title [-]Nexus holds on to a specific service backends of crdb and crucible-pantry for too long[/-][+]Nexus holds on to specific service backends of crdb and crucible-pantry for too long[/+]on Jul 27, 2023
#3783 partially addresses this for crdb. We now, grab all the cockroachdb hosts via internal dns at nexus startup and add them all to the connection string. Whenever a new connection is established it'll try the listed hosts in order and use the first one that successfully connects. While that's an improvement in that Nexus won't fail to serve requests if one crdb instance goes down, there are still some issues:
The list of hosts used are resolved and get fixed at Nexus startup. If new cockroachdb zones get spun up, it'll take a restart of Nexus for it to pick them up. As-is, I don't think we're yet dynamically spinning up new services and instead just creating the service plan during RSS.
In my most recent testing, the behavior for CRDB connection failures has changed (or might be expected?). When the crdb node in use has gone down, I saw messages like this in nexus logs:
17:42:35.701Z ERRO 2898657e-4141-4c05-851b-147bffc6bbbd (ServerContext): database connection error
database_url = postgresql://root@[fd00:1122:3344:109::3]:32221,[fd00:1122:3344:105::3]:32221,[fd00:1122:3344:10b::3]:32221,[fd00:1122:3344:107::3]:32221,[fd00:1122:3344:108::3]:32221/omicron?sslmode=disable
error_message = Connection error: server is shutting down
file = nexus/db-queries/src/db/pool.rs:100
(Note: The crdb instance in use is not necessarily the first one listed; in my case, disabling the 105 instance is what triggered the error.)
Nexus was able to continue serving both read and update API requests in spite of the above error. It's possible that any ongoing requests against the crdb node right at the moment it's going down could have failed but all requests I made afterwards succeeded.
@davepacheco took a look at the code to understand what changed the behavior. Here are his comments:
I didn't think we'd changed anything here since #3763 was filed, but I see there was #3763 (comment), which maybe fixed this? Although subsequent comments suggested it might not have, but it seems like it should have. Anyway, it's good that it worked.
Sorry for not being clear in pantry's case. I understand the need to stay with the same pantry for the same disk snapshot. But the issue I ran into is with new/separate snapshot requests still holding on to the unresponsive one.
Saga pantry attach/detach: fail if pantry is removed from DNS #6866 prevents the snapshot saga from getting stuck in an infinite retry loop if the pantry goes away with particularly-unlucky timing. (The saga will stay stuck until the pantry comes back or is expunged, but either of those events will unstick it.)
Given CRDB and the pantry are both addressed, I'm going to close this. If we run into stale handles to services now that the qorb integration is done, we should file new issues.
Activity
smklein commentedon Jul 25, 2023
I think ignoring the TTL makes sense (not that it's right, just that it makes sense) in the context of this code:
omicron/nexus/src/context.rs
Lines 167 to 195 in a29f08b
Our API to interface with CockroachDB from Nexus involves "constructing a URL", and right now, we embed a single point-in-time address of CockroachDB into this URL.
We should probably avoid doing this, and embed the service name into the URL, so it actually use DNS during later lookups.
askfongjojo commentedon Jul 25, 2023
Understood. The current behavior, in conjunction with #3613, results in an 1 in 15 probability that a user will not be able to use the system at all. I happened to be in this situation when my workstation always used the one nexus that had the first CRDB backend I brought down to test failover. :(
jmpesp commentedon Jul 26, 2023
In this case, there's no TTL: a specific pantry from the list of available ones is selected once and used for a disk until that disk is finalized.
One thing that could be done is to check of the selected pantry is still responsive and choose another one if not, but it was important not keep as much code out of the import chunk hot-path as possible, as any checks there will be multiplied by the number of chunks to import and slow down imports. That being said, slow imports are better than non-working imports :) I'll give this some thought.
askfongjojo commentedon Jul 26, 2023
Sorry for not being clear in pantry's case. I understand the need to stay with the same pantry for the same disk snapshot. But the issue I ran into is with new/separate snapshot requests still holding on to the unresponsive one.
[-]Nexus holds on to a specific service backends of crdb and crucible-pantry for too long[/-][+]Nexus holds on to specific service backends of crdb and crucible-pantry for too long[/+]nexus: use all CockroachDB hosts from DNS to create DB connection URL. (
luqmana commentedon Jul 31, 2023
#3783 partially addresses this for crdb. We now, grab all the cockroachdb hosts via internal dns at nexus startup and add them all to the connection string. Whenever a new connection is established it'll try the listed hosts in order and use the first one that successfully connects. While that's an improvement in that Nexus won't fail to serve requests if one crdb instance goes down, there are still some issues:
14 remaining items
askfongjojo commentedon Jun 21, 2024
In my most recent testing, the behavior for CRDB connection failures has changed (or might be expected?). When the crdb node in use has gone down, I saw messages like this in nexus logs:
(Note: The crdb instance in use is not necessarily the first one listed; in my case, disabling the 105 instance is what triggered the error.)
Nexus was able to continue serving both read and update API requests in spite of the above error. It's possible that any ongoing requests against the crdb node right at the moment it's going down could have failed but all requests I made afterwards succeeded.
@davepacheco took a look at the code to understand what changed the behavior. Here are his comments:
smklein commentedon Jun 25, 2024
Just to be explicit: #5876 will fix this issue for CockroachDB -- in that PR, we use https://github.com/oxidecomputer/qorb to access each CRDB node individually, and create a pool of connections for each one.
Qorb integration as connection pool for database (#5876)
Use a Qorb pool to choose pantry clients (#6822)
[reconfigurator] Add planner support for starting new Crucible pantri…
jgallagher commentedon Nov 18, 2024
I believe this is now fixed for the pantry too:
Given CRDB and the pantry are both addressed, I'm going to close this. If we run into stale handles to services now that the qorb integration is done, we should file new issues.