feat: add process name to 2pc transaction ID#1248
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
| fn test_instance_id() { | ||
| for id in [1024, 11111111, usize::MAX, usize::MIN] { | ||
| let transaction = TwoPcTransaction(id); | ||
| let instance_id = instance_id(); // Generate it, it's a singleton. |
There was a problem hiding this comment.
It feels really gross having TwoPcTransaction rely on global state for its Display impl. Can we separate that out into something that allows the state to be injected?
There was a problem hiding this comment.
It does, yeah. We could call it more explicitly for sure, but we also want to avoid ever rendering a "non-unique" ID by accident.
There was a problem hiding this comment.
Right, I'm thinking we remove the Display impl and have fn display_name(&self, deployment_id: Option<&str>, instance_id: &str), pushing the state up to the caller and making this easier to test
There was a problem hiding this comment.
That'll be a lot of places, which I guess...doesn't really help, since we can fat-finger the calling site. And those are very much invariants/identifiers which we never ever want to confuse.
| instance_id().split("-").last().unwrap().parse() | ||
| } | ||
|
|
||
| static DEPLOYMENT_ID: Lazy<Option<String>> = Lazy::new(|| env::var("DEPLOYMENT_ID").ok()); |
There was a problem hiding this comment.
DEPLOYMENT_ID is a really generic name. Should we prefix this?
There was a problem hiding this comment.
Like PGDOG_DEPLOYMENT_ID or something?
There was a problem hiding this comment.
Maybe. We already use other similar-named env variables there, e.g. NODE_ID. I don't expect ppl to run pgdog in an env shared by another app, and if they do, they certainly wouldn't be sharding, and if they did, I would be like...damn. But yeah, gotta be careful with breaking changes, like I'd want to change all env variables to match the new PGDOG_ format, but I cant :(
Co-authored-by: Sage Griffin <sage@sagetheprogrammer.com>
Co-authored-by: Sage Griffin <sage@sagetheprogrammer.com>
Co-authored-by: Sage Griffin <sage@sagetheprogrammer.com>
This comment has been minimized.
This comment has been minimized.
| for shard in self.shards() { | ||
| shard.wait_schema_loaded().await; | ||
| } |
There was a problem hiding this comment.
These should be able to run in parallel.
There was a problem hiding this comment.
Ah yeah. Those are just waiters, the actual schema fetching runs in parallel, so these will resolve quickly.
|
Still trying to figure out how to get coverage on integration tests -- will use this PR as guinea pig until I give up / it works. |
|
It's accurate, but if this is purely for code coverage purposes I'd be sending SIGINT instead of SITGERM to the server (presumably we already gracefully shutdown on sigint) |
Hmm, I wonder who's sending SIGTERM...nevermind, the call is coming from inside the house, it's our CI script. |
Correct |
|
Aight, well...maybe I'll just keep the handler? It seems like a nice to have feature, plus we get a logline, so that's cool. |

Globally unique transaction ID
Without hopefully going over the 200 bytes limit.
Example:
The last part (the number) can be up to 20 chars long (
usize::MAX), so I'm optimistic people don't name their nodes something 150 characters long, but I may be proven wrong.Misc
SIGTERMhandler which callsstd::process:exit.