Live data from Hacker News

We switched to Java 21 virtual threads and got a deadlock in TPC-C for Postgres

blog.ydb.tech

151–160 of 253 posts

Re: We switched to Java 21 virtual threads and got a deadlock in TPC-C for Postgres

#151
post #116
post #103

Earlier quoted context omitted.

And it indeed does in common usage scenarios. And also in this case once the issue with `synchronized` is resolved. After all, this is a benchmark and it's not surprising that one of the limitations of the design was hit.

"common usage scenarios" != "in all cases". I don't know if those Oracle employees actually did outright say -- or even imply -- "in all cases" as the GP asserted, but if they did, then "only" working in "common usage scenarios" would definitely be overselling the feature.

I find it unlikely as well that they said it would just work in all cases. But since it's going to work out eventually and a workaround exists, they would actually not be that wrong with that statement.

Re: We switched to Java 21 virtual threads and got a deadlock in TPC-C for Postgres

#153

This problem is not going to go away so easily. Numerous core Java classes (like BufferedInputStream) use synchronized. I count 1600+ usages in java.base. The blocking issue means it's _much_ easier to accidentally run into this, rather than waving it away as an unlikely edge case. I personally ran into this Using the built in com.sun webserver, with a virtual thread executor. My VPS only has two CPUs which means the…

People always forget that things that only happen every few million times, can happen fairly frequently on a busy server. This has bitten me numerous times. The nature of a lot of these types of issues is that they are hard to detect and hard to reproduce. Virtual threads are nice for unblocking legacy code but they aren't without issues. There are better options for new code with less trade offs on the jvm as well.…

Was curious what it is "jasync". And man it hurts me to see documentation like this (when compared to classic javadocs)

https://github.com/jasync-sql/jasync-sql/wiki/API-Overview

From project WIKI (https://github.com/jasync-sql/jasync-sql/wiki)

Re: We switched to Java 21 virtual threads and got a deadlock in TPC-C for Postgres

#154

Erlang is based on virtual threads (confusingly called processes). The Erlang virtual machine schedules them on OS threads. Erlang processes communicate using message passing, preventing deadlocks. You can use millions of Erlang processes without problems, e.g., to handle millions of Elixir LiveView sessions.

You can have deadlock in Erlang, it's just a bit harder. It happens when two processes are both waiting on the other to send them a message which is analogous to two threads each waiting for a mutex the other holds. The same thing can happen in Go with its channels, another message passing based concurrency control mechanism.

Two deadlocked processes won't exhaust the thread pool in Erlang, they will simply never wake up.

Re: We switched to Java 21 virtual threads and got a deadlock in TPC-C for Postgres

#155

Earlier quoted context omitted.

I prefer AI generated images over stock photos though. You can tell that both are phony, but at least the AI can be a bit more creative.

I prefer no images over IA stolen/generated images.

What is IA stolen?

Re: We switched to Java 21 virtual threads and got a deadlock in TPC-C for Postgres

#156
post #148

Earlier quoted context omitted.

There's a quality spectrum of AI-generated header images. Some are just random DALL-E output which aren't intrinsically relevant to the article (like the one used in this article), but you can have a little fun with it and do something distinct. This may require more control than just using Bing Image Creator. Also, a thumbnail tip: square thumbnails are bad. If you have to use a square 1024x1024 AI generation, crop…

There's a quality spectrum of AI-generated images, sure, but they're all equally artistically void.

Not all.

Re: We switched to Java 21 virtual threads and got a deadlock in TPC-C for Postgres

#157

Totally off topic but I am getting tired of the AI generated images used on nearly all blog posts nowadays. They are instantly recognisable, it just seems low effort and lowers the feeling of quality one might otherwise have

I like the image. It's cute and it's fun picking out the defects.

Re: We switched to Java 21 virtual threads and got a deadlock in TPC-C for Postgres

#158
post #45

Go has a mechanism to spawn a new thread (m in ho runtime parlance) if it thinks one of its threads might be blocked in a cgo (go’s “native function” equivalent). That prevents stuff like this.

So does C# with active blocking detection (which injects threads to counteract this) and hill climbing algorithm to scale threadpool threads automatically.

Which is very handy sometimes. The default throttling is a bit conservative though and perhaps based on Windows thread costs.

Re: We switched to Java 21 virtual threads and got a deadlock in TPC-C for Postgres

#159

Totally off topic but I am getting tired of the AI generated images used on nearly all blog posts nowadays. They are instantly recognisable, it just seems low effort and lowers the feeling of quality one might otherwise have

I just don't really understand the value they're supposed to bring. If everyone uses the same looking generates images it just makes all the blogs look the same again. Then the thing is, they usually have nothing to do with the actual article. So why not just leave them out and not waste space.

Re: We switched to Java 21 virtual threads and got a deadlock in TPC-C for Postgres

#160

Earlier quoted context omitted.

Java does the same for Object.wait(), only the number of such compensating threads is limited by default, but can be extended via config option. They have exhausted the default number of compensating threads, I think. And they are mistaken to call this situation a "pinning" JEP 444: > The vast majority of blocking operations in the JDK will unmount the virtual thread, freeing its carrier and the underlying OS thread…

> The situation with Object.wait() is not what JEP 444 calls "pinning". The "pinning" happens, for example, when one calls `syncronized(....) {blockingQueue.take()}` [...] To call Object.wait() you need to own the objects monitor, which would imply that your code would actually look like `synchronized(....) {Object.wait()}` in which case you would indeed be pinned.

As I read JEP 444 (starting from the quote above and several following paragraphs, ending with the words "As always, strive to keep locking policies simple and clear."), the term "pinning" is when a blocking function, that normally unmounts virtual thread, does not do so, due to being called from `synchronized` or from native code.

That's different from blocking functions, described in the quote, that does not even try to unmount virtual thread. Like Object.wait().

Pinning is worse than those functions, because the functions compensate for a blocked native thread by adding one more native thread to the pool.

Post reply on HN