News for hackers. Stuff that matters.
Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by codexon on Monday January 06, 2020 @03:24PM (#21972879)
One thing I haven't seen anyone note about clickhouse though which would be really important to many for data durability, is that it does not use fsync anywhere at all.
Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by DasIch on Monday January 06, 2020 @05:37PM (#21974265)
I can't find anything about this in the docs except[1]. I also can't find any issues in their bug tracker related to clickhouse not using fsync[2].

I can however find code that actually calls fsync[3][4]. To be fair I haven't read enough to determine how this (doesn't) affect durability. Nevertheless I'm wondering do you have a source for this claim?

  [1]: https://clickhouse.yandex/docs/en/operations/settings/settings/#fsync-metadata
  [2]: https://github.com/ClickHouse/ClickHouse/search?q=fsync&type=Issues
  [3]: https://github.com/ClickHouse/ClickHouse/blob/355b1e5594119e036a2d62988bfa42bc8b1a1687/dbms/src/IO/WriteBufferFromFileDescriptor.cpp#L113
  [4]: https://github.com/ClickHouse/ClickHouse/blob/e765733a26cfc4cecc13c981686560338256a6b1/dbms/src/IO/WriteBufferAIO.cpp#L98
Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by codexon on Monday January 06, 2020 @08:34PM (#21975810)
As I mentioned, there's only 1 place where it says anything about fsync, and in that page, it says that is only for creating .sql files.

https://groups.google.com/d/msg/clickhouse/cjJ6v8uzu0Q/jGV59...

> The reason is because CH does not use fsync (for performance)

https://www.linkedin.com/in/dzhuravlev/

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by caust1c on Monday January 06, 2020 @03:49PM (#21973150)
It's pretty clearly laid out in the docs. Hopefully anyone seriously considering using Clickhouse reads the docs thoroughly and understands what they're implementing.
Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by codexon on Monday January 06, 2020 @04:32PM (#21973567)
What do you mean clearly laid out? This is the only mention of fsync I could find through google or their own search function.

https://clickhouse.yandex/docs/en/operations/settings/settin...

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by caust1c on Monday January 06, 2020 @05:29PM (#21974186)
The title of the page might be a little snarky, but it's in the introduction that transactional queries are not supported:

https://clickhouse.yandex/docs/en/introduction/features_cons...

Sure it's not specifically about `fsync` but presumably this is what the consumer of the database actually wants to know.

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by codexon on Monday January 06, 2020 @08:17PM (#21975707)
Fsync is not synonymous with transactions. Not using fsync anywhere means there's a wide window that can be over 10 minutes long when data can be lost when a server gets an unplanned shutdown.
Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by valyala on Tuesday January 07, 2020 @06:44PM (#21986543)
Btw, it should be easy adding fsync to ClickHouse. For instance VictoriaMetrics uses similar file format as ClickHouse, and it issues proper fsyncs at least every second, so it may lose only the last second of data on unclean shutdown such as OOM, hardware reset or `kill -9`. [1], [2].

[1] https://medium.com/@valyala/wal-usage-looks-broken-in-modern...

[2] https://medium.com/@valyala/how-victoriametrics-makes-instan...

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by FridgeSeal on Monday January 06, 2020 @04:51PM (#21973779)
I’m not understanding the implication of this, could you explain?
Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by DasIch on Monday January 06, 2020 @05:43PM (#21974316)
When you write to a file, you generally don't write to physical storage. Instead the writes get buffered in memory and written to physical storage in batches. This substantially improves performance but creates a risk: If there is some sort of outage before the data is flushed to disk, you might lose data.

In order to address that risk, you can explicitly force data to be written to disk by calling fsync. Databases generally do this to ensure durability and only signal success after fsync succeeded and the data is safely stored.

So ClickHouse not calling fsync implies that it might lose data in case of a power outage or a similar event.

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by hodgesrm on Tuesday January 07, 2020 @08:03PM (#21987159)
Most ClickHouse installations run replication for availability and read scaling. If you do get corrupted data for some reason, you can read it back from another replica. That's much more efficient than trying to fsync transactions, especially on HDD. The performance penalty for fsyncs can be substantial and most users seem to be pleased with the trade-off to get more speed.

This would obviously be a poor trade-off for handling financial transactions or storing complex objects that depend on referential integrity to function correctly. But people don't use ClickHouse to solve those problems. It's mostly append-only datasets for analytic applications.

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by somurzakov on Monday January 06, 2020 @07:45PM (#21975412)
is this really that important, thought, since all servers feed power from uninterruptible power supply and most data centers have multiple power sources.
Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by DasIch on Tuesday January 07, 2020 @03:58PM (#21984773)
It’s a significant deviation from what I would expect from a disk oriented database. So I would definitely expect it to be well documented, along with the reason for it, why the developers believe it is a reasonable (or even safe) choice, what assumptions went into that (such as availability of uninterruptible power supply) etc.

Additionally keep in mind that with EBS most people probably use network attached storage and fsync involves the network. Outage doesn’t just mean power outage, it could also be a network issue.

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by caust1c on Monday January 06, 2020 @05:31PM (#21974205)
The implication is that clickhouse can't easily support transactional queries. That's why it's an OLAP not OLTP database. (On-Line Analytics Processing vs On-Line Transaction Processing).
Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by codexon on Monday January 06, 2020 @08:21PM (#21975731)
This is not the implication at all.

Clickhouse can easily add fsync, they just choose not to do it.

Mongodb also did not use fsync and was ridiculed for it, yet no one mentions this about clickhouse.

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by pritambaral on Tuesday January 07, 2020 @05:06AM (#21978559)
> Mongodb also did not use fsync and was ridiculed for it, yet no one mentions this about clickhouse.

MongoDB claimed to be a replacement for RDBMS-es (which includes OLTP). ClickHouse is explicit about being OLAP-only. MongoDB also hid the fact that they weren't doing fsync, especially when showing off "benchmarks" against OLTP RDBMS-es, while ClickHouse has not tried to show themselves as a replacement for OLTP RDBMS-es.

> Clickhouse can easily add fsync, they just choose not to do it.

For good reason. It's not a simple matter of choosing one of two options. The choice has consequences: performance.

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by codexon on Tuesday January 07, 2020 @04:05PM (#21984836)
I can't find any evidence showing that OLAP means it is okay to lose data from unexpected shutdowns. How can you have correct analytics without a complete set of data?

> For good reason. It's not a simple matter of choosing one of two options. The choice has consequences: performance.

It is a simple matter though. They can choose to sacrifice performance for data durability which I suspect would not be impacted very much since clickhouse acts like an append log. It just seems that Yandex doesn't care much for durability since they are just using the database to store people's web traffic. They wouldn't care if some of that data is lost so they don't use fsync.

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by pritambaral on Monday January 20, 2020 @12:21PM (#22100368)
> I can't find any evidence showing that OLAP means it is okay to ...

OLAP also doesn't mean "be the source of truth of the data". You can have a separate source of truth of the "complete set of data" outside of your OLAP engine and load (and reload) data into your OLAP engine any time you're not sure if you have the "complete set of data" in it.

The important difference lies in how often one finds themselves in that situation. In OLAP, the sheer majority of the time is spent querying (i.e., reading) data than loading (i.e., writing) data and waiting for it to be durably saved (i.e., fsync-ed). Because of this imbalance, it makes sense to prioritise for one scenario and handle the other sub-optimally.

> They wouldn't care if some of that data is lost so they don't use fsync.

Or, they can still care about data correctness and simply re-load data they suspect is/may not consistent in the rare case of an improper shutdown. It's not like they use ClickHouse as their primary data store.

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by jayleeg on Tuesday January 07, 2020 @06:38AM (#21979034)
To add to pritambaral comments.

The top commercial high performance timeseries databases, which ClickHouse can usually best, used by banks to make decisions on your money also don't use fsync. You can literally quit the software and watch your transaction data be written out 5 seconds later.

Edit: a word

Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by FridgeSeal on Monday January 06, 2020 @07:20PM (#21975209)
Oh that’s not too bad, they’re very explicit about not having transaction support, thanks for explaining.
Re:ClickHouse cost-efficiency in action: analyzing 500B rows... by gautamcgoel on Monday January 06, 2020 @05:53PM (#21974410)
Yes, I have the same model. I think I bought it for between $650 and $750.