News for hackers. Stuff that matters.
Re:Logbookd – SQLite Backed Syslogd by righthand on Sunday September 15, 2024 @08:59AM (#41547249)
This looks right up my alley. I am experimenting to see how much I can strip systemd from my every day laptop as an exercise in futility and to understand how embedded a distribution like Debian has become.
Re:Logbookd – SQLite Backed Syslogd by UI_at_80x24 on Sunday September 15, 2024 @09:56AM (#41547541)
I stopped trying to swim against the current and switched to OpenBSD/FreeBSD. You might be surprised how viable it really is.
Re:Logbookd – SQLite Backed Syslogd by koeng on Sunday September 15, 2024 @11:15AM (#41547970)
It’s really a shame that OpenBSD doesn’t have a good file system. Otherwise I’d use for my production systems (I could put it inside of proxmox, with a ZFS container outside for stability inside, but I like to run bare metal, no VMs)
Re:Logbookd – SQLite Backed Syslogd by ivzhh on Sunday September 15, 2024 @01:27PM (#41548870)
I tried to install OpenBSD on three VM hosts, one Macbook Intel, one FreeBSD and one KVM. OpenBSD failed to install in all three environments. The latter two crashed just during the file system creation stage.
Re:Logbookd – SQLite Backed Syslogd by yjftsjthsd-h on Sunday September 15, 2024 @12:00PM (#41548249)
I think Alpine would be a smaller jump?
Re:Logbookd – SQLite Backed Syslogd by ivzhh on Sunday September 15, 2024 @01:28PM (#41548885)
Yes, Alpine is a good choice for small servers. I run both FreeBSD and Alpine for my homelab. Alpine feels very close to FreeBSD style. I still prefer pf over ufw/awall.
Re:Logbookd – SQLite Backed Syslogd by pwg on Sunday September 15, 2024 @11:22AM (#41548008)
Slackware is also systemd free.

http://www.slackware.com/

Re:Logbookd – SQLite Backed Syslogd by righthand on Sunday September 15, 2024 @03:49PM (#41549818)
That’s my concern, the Debian experience is usually pretty lovely and I’d hate to leave it behind, but maybe there’s no point in fiddling with something stuck in trends.
Re:Logbookd – SQLite Backed Syslogd by tristan957 on Sunday September 15, 2024 @09:57PM (#41552045)
Re:Logbookd – SQLite Backed Syslogd by nine_k on Sunday September 15, 2024 @05:27PM (#41550574)
I run Void Linux on my laptop, which seems to exhibit many BSD-esque approaches (and lacks systemd), while also being a rolling release distro with fresh stuff usually appearing in a few days after an upstream release.

Pretty fine so far (about 6 years).

Re:Logbookd – SQLite Backed Syslogd by LargoLasskhyfv on Tuesday September 17, 2024 @09:21AM (#41567343)
That's the spirit!

https://www.antixforum.com/forums/topic/antix-23-1_init-dive...

Seems that it even saves power, in spite of using that gaming/latency-optimized kernel from Pika-OS.

Re:Logbookd – SQLite Backed Syslogd by pzmarzly on Sunday September 15, 2024 @09:10AM (#41547296)

  -g kB       Remove old log lines when the in-memory database crosses x kB
Seems like garbage collection is only implemented for in-memory database (by reading SQLITE_DBSTATUS_CACHE_USED). Maybe logrotate could be set up to do it instead, but nothing in documentation indicates so.

Otherwise looks like a great project.

Re:Logbookd – SQLite Backed Syslogd by thebeardisred on Sunday September 15, 2024 @11:09AM (#41547936)
What's the maximum write speed? At what point do you start losing log messages?
Re:Logbookd – SQLite Backed Syslogd by bubblesnort on Sunday September 15, 2024 @12:49PM (#41548577)
I don't think this is going to be an issue as Linux has a built-in rate limiter.
Re:Logbookd – SQLite Backed Syslogd by cryptonector on Sunday September 15, 2024 @01:10PM (#41548734)
That's not GP's question. GP wants to know how high the write rate can be regardless of the systemd log rate limiter, likely so as to be able to increase that rate limit!
Re:Logbookd – SQLite Backed Syslogd by thebeardisred on Tuesday September 17, 2024 @12:41PM (#41569621)
This is a core design challenge for all logging systems. This is why there are mechanisms for intentionally dropping messages to relieve queue pressure, optimizations around the use of IO_URING. Inversely because logging systems can drop messages it is one of the primary reasons for "MARK" type mechanisms (https://lists.debian.org/debian-user/1998/09/msg00915.html).
Re:Logbookd – SQLite Backed Syslogd by cryptonector on Sunday September 15, 2024 @01:08PM (#41548722)
You can amortize the write speed significantly by not committing often, either in the sense of a SQL `COMMIT` or in the sense of doing a _synchronous_ `COMMIT`. You could commit every N seconds, say, for some sufficiently large N, or you could commit after N seconds of idle time and no more than M seconds since the last commit. You can also disable `fsync()`, commit often, and re-enable `fsync()` once every N seconds. There are many tactics you can use for data where some loss due to power failure is tolerable.

I.e., you can probably get pretty close to the storage device's max sustained write throughput, though with some losses for write magnification due, e.g., to B-tree write magnification and also indices you might want to maintain.

Write magnification due to B-tree write magnification can be amortized by committing infrequently (which is why I listed that _first_ above). Though there should be no need because SQLite3 already amortizes B-tree write magnification by using a write-ahead log (WAL), so be sure to enable the WAL for this sort of application.

Write magnification due to indices can be amortized by partitioning your tables by time ranges, and then use a VIEW to unify your tables, and then you can create an index on any partition only when it closes to new log entries. This approach causes reads to be slow when searching newer log entries, but those probably will all fit in memory, so it's not a problem if you have a large enough page cache.

Now I've not built anything like this so I can't say for sure, but I suspect that one could get very aggressive with these techniques and reach a sustained write rate of around 75% of the storage device(s)' sustained write rate.

Re:Logbookd – SQLite Backed Syslogd by singron on Sunday September 15, 2024 @01:51PM (#41549051)
Turning off fsync is pretty dangerous since a crash could corrupt the database. You might think you would just lose a couple seconds of data, but that's only true if writes are applied in order.

E.g. if some data is moved from page A to page B, you normally write B with the new data, fsync, and then write A without the data. Without fsync, you might only write page A and you would lose that data. This might happen on a internal data structure and corrupt the whole database.

Re:Logbookd – SQLite Backed Syslogd by cryptonector on Sunday September 15, 2024 @02:25PM (#41549295)
You could also disable sync writes for the WAL but enable them for the main DB.
Re:Logbookd – SQLite Backed Syslogd by Spivak on Sunday September 15, 2024 @11:28AM (#41548061)
I'm actually kinda surprised they went with SQLite here, log messages are the trivialest data format and there's no way you can't beat SQLite's speed by just not having database logic in the middle at all. Just being able to BYOAllocator for the logs themselves with such predictable linear memory usage would make this thing scream.
Re:Logbookd – SQLite Backed Syslogd by WhyNotHugo on Sunday September 15, 2024 @12:02PM (#41548268)
The advantage of SQLite is being able to perform queries like “logs for service X and Y yesterday between 15hs and 16hs”.
Re:Logbookd – SQLite Backed Syslogd by nolist_policy on Sunday September 15, 2024 @02:24PM (#41549287)

  journalctl -u ssh.service -u exim4.service --since='2024-09-14 15:00' --until='2024-09-14 16:00'
(Systemd accepts e.g. 'yesterday' as a timestamp but not together with a time)
Re:Logbookd – SQLite Backed Syslogd by dmd on Sunday September 15, 2024 @11:48AM (#41548174)
Re:Logbookd – SQLite Backed Syslogd by cryptonector on Sunday September 15, 2024 @01:13PM (#41548754)
You're sort of right in that a B-tree is not a good data structure for logs given that append-only files are perfect for logs. But the point of using an RDBMS for logs is to be able to a) index the logs, b) provide a great search facility for logs. Perhaps a better design would be a virtual table plugin for SQLite3 that allows one to use log files as tables, then index and search them with SQLite3, but if one lacks the time to investigate that approach then oe can't be faulted for using SQLite3 directly.
Re:Logbookd – SQLite Backed Syslogd by ivzhh on Sunday September 15, 2024 @01:31PM (#41548917)
Agree, /var/log/messages is there for a long time, writing to log is never a problem. Digesting the log is the niche market and it is profitable enough that we have a lot of tools in this market (rotation, transmission, parsing, etc)
Re:Logbookd – SQLite Backed Syslogd by marcrosoft on Sunday September 15, 2024 @12:44PM (#41548539)
I did something similar but not open source: centrallogging.com it is surprising how SQLite can scale for smallish amounts of logs (1tb)
Re:Logbookd – SQLite Backed Syslogd by simscitizen on Sunday September 15, 2024 @01:04PM (#41548691)
How does this work exactly? Is every log line a separate transaction in autocommit mode? Because I don't see any begin/commit statements in this codebase so far...
Re:Logbookd – SQLite Backed Syslogd by nine_k on Sunday September 15, 2024 @05:23PM (#41550548)
Maybe autocommit mode is set? I'd expect that.
Re:Logbookd – SQLite Backed Syslogd by simscitizen on Monday September 16, 2024 @12:21AM (#41552736)
Inserting a new row for each log line in autocommit mode would be absurdly inefficient compared to just appending a log line to a file.
Re:Logbookd – SQLite Backed Syslogd by juvenn on Sunday September 15, 2024 @10:54PM (#41552322)
Why not use duckdb? It is a column database, and more situated for log entries (seems to me).