7 ms·
Pending and rolled back are different transaction states. The former uses resources and locks and can prevent other transactions from happening. Rolling back a
by shpx 2y ago
Pending and rolled back are different transaction states. The former uses resources and locks and can prevent other transactions from happening.
Rolling back a transaction twice probably indicates an error in your program, which Go's API is giving you a chance to report to yourself.
Ultimately every network request can fail because of the Two Generals' Problem. Actually, every single operation on a computer can fail (as in, do something other than what you were promised or promised yourself it would do). Nothing in life is guaranteed, the environment is adversarial. The fact that we create machines that can be predicted with 0.00000000001% certainty and carve out a safe environment for them and feed them energy is not common and unnatural and all computers will also eventually succumb to entropy. The network is just where that is common enough that considering that another computer can die in our programs can be more useful than completely ignoring the possibility. This possibility is represented as a non-zero number called "error" in the Go API you've posted, so that you have the option of branching your program to a different execution path if the database you're communicating with stops existing or at least stops being reachable.
- haiku2077 2y agoFalsehoods programmers believe: - Sleep(1) sleeps for exactly 1 second. - Sleep(1) sleeps for approximately 1 second. - Sleep(1) sleeps for at least 1 second. - Sleep(1) sleeps for an unknown, but short amount of time. Certainly not weeks, months or years.
- deleted 2y ago[deleted]
- teddyh 2y agoMore Falsehoods programmers believe about time: <https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b923ca https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b...>
- Dylan16807 2y ago"Approximately 1 second" is fine. You just have to keep in mind that other influences can block your program from running. Those other influences can trigger even if you don't sleep!
- a1369209993 2y ago> Sleep(1) sleeps for approximately 1 second. This is correct - Sleep(1) does sleep for approximately 1 second; the problem is you're confusing the 95% confidence interval (which might be as narrow as (999ms,1001ms) for some reasonable designs) with the absolute error bounds (which are (0ms,∞ms], and yes, the infinity end is inclusive).
- haiku2077 2y agoIf your software is running on a VM, and that VM is suspended (e.g. for migration), the end of sleep could be minutes or months in future. This is surprisingly common when running on certain VM instance types on public cloud! Common enough that I've had to account for it in production code.
- trifurcate 2y agoThe confidence interval comment still applies for any production or client environment I've ever deployed code to. Unless you actually expect your environment to spend more than 5% of its time on average getting suspended and resumed. Maybe you work on some tooling that is scheduled to run right around migration time (for servers) or sleep/resume time (for clients).
- haiku2077 2y agoOr you run at scale on a public cloud provider. We observe a few of these events per month.
- NemoNobody 2y agoHaha, this is one of the best comments I've read on HN