Better HN
topnewbestaskshowjobs
Log inSign up

randomdata

8,634 karma · joined Jun 23, 2011 (15y ago) · 7,679 submissions

Submissions

comment 2y ago · link · parent

The bug of which we speak is in that your app is crashing. Exhausting open file handles is expected behaviour! Expected behaviour should not lead to a crash. Crashing is only for exceptional behaviour.

The filesystem hanging is unlikely to be a bug. The filesystems you'd realistically use in conjunction with Kubernetes are pretty heavily tested. More likely it is supposed to hang under whatever conditions has lead that to happen.

And, sure, maybe you'll eventually want to determine why the filesystem has moved into that failure state, but most pressing is that your app is crashing. All that work you put into gracefully handling the failing situation going to waste.

comment 2y ago · link · parent

> errors.Is is true for whatever x.Close() returned.

That may get you through if there is only one x.Close, but now you have to offer the guarantee to the callers that there will only ever be one Close error returned. Furthermore, any callers of your function have to ensure that they don't end up introducing additional Close error returns in the same vein.

Without such guarantees, you, the caller, need to resort to string matching to protect against undocumented functionality and/or future modifications when you handle the error. Sounds like a rough situation...

> If I'm going to do something upstream based on the error, I use a type.

Implying that you are a lone wolf developer? I think you make a good point that if you exist in your own world without other developers just about anything goes.

That said, the language used around the previously linked repository implies that it welcomes other developers using and working on the code, so it is not clear how you are "doing the upstream" in all cases.

comment 2y ago · link · parent

Let me introduce you to the question mark, seen on your screen as the '?' character. It indicates that a question is asked. This is important as...

Never has "who cares" been confidently said. It has always been asked "who cares?". And not asked in a vacuum either, but specifically asked alongside the question of what is to be gained from the knowledge of the error.

We now know that you allegedly care, which is a promising start. But you purposefully ignored the other question, which questions the credibly of your care. You can't meaningfully care about something if you don't know why you care about it, and if you knew you'd have told us about it already as it nonsensical to answer to the "who cares?" question alone, so...

comment 2y ago · link · parent

> Stringly typed errors are also idiomatic in go, if you follow the stdlib.

Realistically, you can't follow the standard library, except perhaps the newest additions. Idioms emerge and evolve with use. Much of the standard library was written before Go saw much use, being largely in place before the world got to see Go for the first time. Also, thanks to the Go1 guarantee, cannot be changed now.

If the aforementioned package was written in the 2000s, then it might be fair to say that it was in line with the idioms of the time. But it appears to have been written within the last year, and thus is not aligned with idioms of its age.

That's not to say it has to be. Idioms are not requirements. The "stringly-typed" design may be justified even knowing what we know in the 2020s. And, with that, we don't need to speculate about the justifications. We can let the author speak for himself as to why the choice was made.

comment 2y ago · link · parent

> which to be honest is the _correct_ logic in many cases

It is almost never the correct logic. The only time it might be appropriate is in a private helper function that has limited scope around another function.

It is most definitely not the correct logic if you are returning that from a public function! For many reasons, but especially because it now binds you to the implementation of the function you called forevermore. That is a horrible place to be.

For example, find out your os.File usage would be better served by SQLite? Too bad. You can't change it now because the users of your function have come to rely on errors from the os file operations when they handle the error you give them. Their code can't deal with the errors coming out of SQLite.

Instead, you need to return errors that are relevant to your function. It may be appropriate to wrap the source error in some circumstances, but your error structures should compel the user to rely on your errors, leaving the wrapped error only for things like logging where a change in the future won't break the callers.

comment 2y ago · link · parent

With your package, how do you suggest users of your function handle the error upstream?

Like this?

   switch {
   case strings.Contains(err.Error(), "close thing foo"):
       // deal with foo close error
   case strings.Contains(err.Error(), "close thing bar"):
       // deal with bar close error
   }
And if so, what lead you or your organization to prefer "stringly-typed" errors over the idiomatic approach?

comment 2y ago · link · parent

In the current formal sense. It may be true the formal sense in 1986 was different. Words do evolve in meaning over time, but since we're talking about right now...

You are right that lying and bullshitting are different. A lie is a false statement with intent. Bullshit is nonsense with intent. A false statement and nonsense may share some similarities, but are ultimately different.

Perhaps nonsense is the word we should be applying to LLMs, but often what they say isn't nonsense, even if only by accident, so that doesn't exactly work either. Regardless, it doesn't matter now. As before, "hallucination" has moved beyond analogy and now has its own LLM-specific usage.

comment 2y ago · link · parent

A file not able to opened is expected, always! accept is no exception here. Your application should not be crashing because of it.

If I recall, Kubernetes performs health checks over HTTP, so presumably your application is using the standard library's http server to provide that? If so, accept is full abstracted away. So, if that's crashing, that's a bug in Go.

Is that for you to debug, or is it best passed on to the Go team?

comment 2y ago · link · parent

> becomes the error returned by the entire function

If you find the error returned by f.Close to be significant, are you sure returning again it is the right course of action? Most likely you want to do something more meaningful with that state, like retrying the write with an alternate storage device.

Returning the error is giving up, and giving up just because a file didn't close does not make for a very robust system. Not all programs need to be robust, necessarily, but Go is definitely geared towards building systems that are intended to be robust.

comment 2y ago · link · parent

To start, you need to figure out why Kubernetes isn't retaining your stack trace/related metadata when the app crashes. That is the most pressing bug. Which is probably best left to the k9s team. You outsourced that aspect of the business of good reason, no doubt.

After they've fixed what they need to fix you need to use the information now being retained to narrow down why your app is crashing at all. Failing to open a file is expected behaviour. It should not be crashing.

Then maybe you can get around to looking at the close issue. But it's the least of your concerns. You've got way bigger problems to tackle first.

comment 2y ago · link · parent

Apple sells around 200 million model year units at a profit of around $400 per device. That's $80 billion in potential profit, less R&D costs.

You think you can build something at least as compelling as the iPhone from the ground up for less than $80 billion? Apple is spending $30 billion on R&D a year just to improve what they already have! Good luck...

And you only get one year to capitalize on that investment, more or less. By year two, without even more investment, the competition will have you smoked with their latest offerings. You might not even get a whole year if they see you as a credible threat. Nothing says the iPhone must be released on a yearly schedule.

comment 2y ago · link · parent

> the lesson to be drawn from that is "don't defer a function call if you need to check its error value"

Isn't the lesson here: If you must have a Close method that might fail in your API, ensure it can safely be called multiple times?

As long as that is true, you can approach it like you would any other API that has resources that might need to be cleaned up.

    f, _ := os.Create(...)
    defer f.Close()
    // perform writes and whatever else
    if err := f.Close(); err != nil {
        // recover from failure
    }
(os.File supports this, expectedly)

> the solution to this problem will be to use a WriteFile function

If it were the solution you'd already be using os.WriteFile. It has a time and place, but often it is not suitable. Notably because it requires the entire file contents to be first stored in memory, which can become problematic.

Certainly you could write a custom WriteFile function that is tuned to your specific requirements, but now you're back to needing to be familiar with the intricacies of a lower-level API in order to facilitate that.

comment 2y ago · link · parent

Bullshitting implies intent to deceive. As far as we know, an LLM honestly "believes" (as if you need another rabbit hole) what it says. Delusion, perhaps?

Delusion implies a degree of consistency, though. LLMs can be on point one minute and completely off the rails the next even when prompted with the same prompt. Hallucination fits better here as it speaks to the real-time "perception" (there's another one for you).

An LLM is not a brain, though, so no matter which analogy you choose, it will come with some flaws. Regardless, "hallucination" has moved past analogy territory and now has its own LLM-specific usage with reasonably wide acceptance so the analogy angle is now moot anyway.

comment 2y ago · link · parent

You'd guess wrong. We have record keeping around how most people use words, and according to those records "white collar" is used in this fashion of: "relating to the work done or those who work in an office or other professional environment."

And you confirm that they work in an office environment, so that bit isn't in question. Perhaps you are confusing most with all? It is certain that not everyone sees "white collar" that way, but we're not talking about everyone.

comment 2y ago · link · parent

> if a write fails.

We're talking about a read-only case. os.Open returns a read-only file handle. If you try writing to it, you'll get an error already at that point. If close fails, who cares?

> I'm not sure how they would handle a file close failure

Ideally there is some kind of failover you can resort to, but if there is no other option at very least you will want to notify a human that what they thought was written isn't actually. But when only reading, you don't need to fall back to anything – all the reads were successful – and what is it to the human? What they thought was supposed to happen did!

comment 2y ago · link · parent

You can't safely assume that, but what are you going to do about it when it does fail? There is nothing you can do. There isn't usually a CloseClose function to use when Close fails. If Close fails, that's it. You're otherwise out of luck.

Certainly, in the write failure case where there is write failure you'd want to try writing to something else (ideally), notify someone that an operation didn't happen (as a last resort), or something to that effect in order to recover.

But in this case there is no need to try again and nobody really cares. Everything you needed the resources for is already successfully completed. If there is failure when releasing those resources, so what? There is nothing you can do about it.

comment 2y ago · link · parent

Pay is clearly irrelevant. White/blue collar is not defined by pay. Certain tradesmen are earning as much as SWEs – sometimes even more – but are considered blue collar by most. Again, it is about the environment in which the work is done.

Office environment is key to what you say. That is why you would be considered white collar. The literal white collars may be gone, but what you call "dressing like slobs" is just a modern adaptation of the same white collar idea.

Now, as it pertains to tellers, banks are typically considered to be an office environment, thus why most consider them to be white collar.

comment 2y ago · link · parent

> It's more of a service industry position

Banks are in the service industry (as is just about everything else; only resource extraction and manufacturing are excluded), so not just "more of". It is definitively a service industry position.

> like being a cashier.

The physical action of the work is a lot like being a cashier, but the environment in which the work is done is usually different, and that environment (especially with respect to the type of clothing the people usually wear within that environment) is what traditionally defines "white collar". As such, tellers are considered white collar by most people.

comment 2y ago · link · parent

> Are they not common in Canada?

I'm not sure they were ever common, but certainly exist. A lot of them have been since removed, though, making them less common than they used to be.

comment 2y ago · link · parent

Perhaps the COVID situation saw a temporary exodus from the cities, but it seems since most people have returned. It would appear that people still care about concentrating assets in a community. That is, after all, why cities exist.

comment 2y ago · link · parent

That's not it. You can't write to a file handle returned by os.Open.

https://pkg.go.dev/os#Open

    func Open(name string) (*File, error)
    Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

comment 2y ago · link · parent

If what I say is true, the people are still apt to buy a new phone instead of a new battery. As before, once you've overcome the friction of having to buy something new, you're going to evaluate all the options.

But let's assume what the OP says is true. It is still not clear why anyone would do what you suggest? The investment required to be that player would be intense and knowing that you only have one product lifecycle to recoup it... Highly unlikely anyone is that daring. Competition sees players seek to be the winner, not the first loser.

comment 2y ago · link · parent

You seem confused. The article is about writing a file where it does matter, but the comment example, which is what we're talking about, only reads a file. If close fails after read, who gives a shit? What difference is it going to make? All your read operations are complete already. Close isn't going to trigger a time machine that goes back and time and undos the reads you've performed. It is entirely inconsequential.

comment 2y ago · link · parent

Competition. Once the battery has gone bad and the user has decided that they are going to get a new phone to replace it, they are going to evaluate Apple's offering against all other phones they can buy. If Apple's device doesn't look as compelling as Samsung's (or whatever), the person is apt to buy something else.

But if the battery was working as well as it did when it was new, it is unlikely that the person would have started shopping in the first place. It is the catalyst that sees them move beyond "what I've got is good enough" to "this isn't serving my needs anymore".

comment 2y ago · link · parent

I'm not sure your proof works. In the absence of collusion, you'd expect vendors selling the same thing to ultimately end up with the exact same prices. After all, why would the customer keep buying from Player B if Player A is selling the exact same thing for less? The only way Player B has any chance of finding any customers and dividing the market, without some other differentiating factor, is to sell at the same price as Player A.

If anything, Costco's higher prices is more likely to suggest collusion (but still does not imply it).

comment 2y ago · link · parent

Your list isn't quite right. I produce in two of those agriculture sectors in Canada. I'm able to charge whatever price I see fit for my products, independent of anyone else producing something similar. About the only thing that comes close in the one instance, which may be what you're thinking of, is if I decide to sell my product through the government store (optional) I contractually cannot sell my product at a different price in my store – but I still get to set the price used in both places. There are no encumberments to speak of in the other case. It is about as "free market" as it gets.

At the same time, you missed eggs and poultry, which are also under supply management like dairy. If we're to be technical it the milk/egg/chicken/turkey marketing board is responsible for managing the supply and therefore prices, which is decidedly not a government entity, but the existence is granted by the government so we'll give you that one.

1
192021
256