DataReel 7.3.1 Beta Release Notes
Fixes
Tests
DATABASE REPLICATION (added 11/07/2026, beta)
DataReel 7.3.2 fixes database replication (gxrepl) problems found in production; see RELEASE_NOTES_7.3.2.txt.
DataReel 7.3.1 is a beta bug fix release of 7.3. DataReel 7.4.1 (11/20/2026) is now the stable release, and DataReel 6.4.2 the legacy release (bug fixes and security updates only); please report problems through https://datareel.com/contact.php.
7.3.1 fixes the problems found by a security scan of the object database code (gxDatabase, gxBtree, BtreeCache, gxdJournal, the page cache and the file I/O layer) and by a full sweep of the rest of the library (TLS, the gxStream database protocol, HTTP, SMTP, POP3, FTPS, telnet, RS-232, ping, config, log file, thread pool and the repair tools), and adds mutual TLS to gxStream database servers. The file formats are unchanged and the API changes are additions. Rebuild programs against 7.3.1.
The library version is 7.3.1 (version.txt, DATAREEL_VERSION_STRING in gxdlcode.h, libdatareel.so.7.3.1); the soname stays libdatareel.so.7.
Fixes
1. gxDatabase::TotalBlocks() on a damaged file: a block length of
zero looped for ever, tiny lengths rescanned the same bytes again and again, and in the 64-bit engine a huge length wrapped the address back to an earlier block (an endless count). Lengths shorter than a block header or past the end of the file are now skipped like any bad block. (Found by fuzzing.)
2. gxDatabase::CalcChecksum(): the end of file came from the file
header, so a damaged header could ask for a buffer of any size. It is now limited by the real file size. (Found by fuzzing.)
3. gxDatabase::Close(): a file that failed the signature test in
Open() was never closed, leaking one file descriptor or handle per failed open (a bug since 6.x). Close() now closes any open file and still never writes a header to a file that failed the checks. (Found by LeakSanitizer.)
4. gxdJournal::Recover(): pages past a file's committed size are
skipped, so a damaged page number cannot become a wrapped file offset, and a commit record with a file size the file address type cannot hold ends the replay. (Found by static analysis and fuzzing.)
5. gxDatabase::WriteObjectChecksum() returned an uninitialised value
when the file was not open. (Found by static analysis.)
SECURITY SWEEP FIXES (summary; the full list with tests is in DATAREEL_73_FULL_SECURITY_SWEEP.md in the project notes)
- TLS: a failed handshake or certificate check closes the socket (no plaintext fallback); handshakes, reads and writes honour the connection timeout (gxSocket::SetIOTimeout); FTPS data connections check the server certificate when the session is not resumed; Close() no longer waits for the peer; SIGPIPE no longer stops servers; size truncations removed; private key files written 0600.
- gxStream: refuses non-TLS connections; 64-bit result addresses; the stream_server example validates requested blocks and obeys a remote shutdown only with --allow-remote-shutdown.
- HTTP: interim response flood, strict status/headers/framing (no Content-Length + chunked), control characters, redirect header leaks, body size caps. URL DecodeStrict(). FTP SIZE and PASV/EPSV parsing; SMTP address injection; POP3 and FTP size caps. The HTTPS server example refuses dotfiles, symlink escapes and device names.
- Telnet pattern search bounds, lone IAC, subnegotiation and option loops; RS-232 endless reads/writes, block overflow, termios restore (DTR), O_ASYNC (SIGIO stopped the program), Windows error checks; ping reply checks; gxConfig key matching and CR/LF; LogFile mode 0640 and CR/LF; ThreadPool start/stop; db_debug damaged files.
Mutual TLS for gxStream database servers (gxstls.h, gxstream.h, gxssl.h)
Section text for RELEASE_NOTES_7.3.1.txt, 11/01/2026.
gxStream servers now require client certificates and accept only
the clients in an allow list. The check is on by default for
database servers and off for other TLS servers.
Servers
- New gxStreamServer (gxstream.h), a gxsTLSServer for gxStream
clients. Before Listen(), call SetClientCAFile("client_ca.pem")
and allow clients with AllowClientFingerprint(sha256) and/or
AllowClientCN(name). Listen() fails, with Error() saying why,
if the client CA file or the allow list is missing. An open
server needs an explicit AllowAnonymousClients(true).
Accept(gxStream &) accepts a client into a stream.
- New gxsTLSServer functions: SetClientCAFile(), ClientCAFile(),
AllowClientFingerprint(), AllowClientCN(),
ClearClientAllowList(), AllowedFingerprints(), AllowedCNs(),
SetRequireClientAuth(), RequireClientAuth(),
AllowAnonymousClients(), AnonymousClientsAllowed() and the
static NormalizeFingerprint().
- With a client CA file set, the server asks every client for a
certificate. Only the CAs in that file are trusted for client
certificates, not the system store. After the handshake
Accept() checks that a certificate was sent, that its chain
verifies, and that its SHA-256 fingerprint or subject CN is in
the allow list. If any check fails the connection is closed
and Accept() returns -1 (fail closed). With a client CA file and
an empty allow list (possible only on a plain gxsTLSServer), any
certificate from those CAs is accepted.
- Fingerprints are 32 hex bytes, with or without colons and in
either case; the "sha256 Fingerprint=" prefix printed by
"openssl x509 -noout -fingerprint -sha256" is skipped. CN
matches are exact and case sensitive. A certificate with no CN,
more than one CN, or a NUL in the CN matches only by
fingerprint.
- The accepted gxsTLSConnection reports the client's identity:
ClientAuthenticated(), PeerFingerprint() (upper case hex with
colons) and PeerCN() (UTF-8). These come from the client's
certificate, so escape control characters before logging them.
- A plain gxsTLSServer (HTTPS server, tls_echo_server and other
TLS servers) does not ask for client certificates unless
SetClientCAFile() is called. Only gxStreamServer, or a server
that calls SetRequireClientAuth(true), refuses to start without
the setup. A program that serves gxStream with a plain
gxsTLSServer keeps working but has no client check; switch it
to gxStreamServer.
- Call Accept() for every client. AttachServer() with the server
context checks the certificate chain (OpenSSL) but not the
allow list.
Clients
- New gxStream::SetClientCert(cert, key, passphrase), the same as
Connection().SetClientCert(), sets the certificate and key sent
to the server. Set it before Connect(). With TLS 1.3 a refused
client finds out on its first read or write after Connect(),
not in Connect() itself.
- Schannel (Windows) clients load the certificate and key the
same way as Schannel servers: a PEM or DER certificate with a
PEM/DER PKCS#8, RSA or EC key (the key is imported into the
current user's key store while the context exists), or a .pfx
or .p12 file passed as the certificate with an empty key file.
gxSSL
- New SetClientCAList()/ClientCAList(), VerifyClientCert() and
GetPeerCertIdentity() (OpenSSL and Schannel). OpenSSL servers
use SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, send the
client CA names and set a session ID context so resumed
sessions still work. Schannel servers request client
certificates with ASC_REQ_MUTUAL_AUTH and check the chain the
same way VerifyCert() checks a server against a CA list: the
root must be in the client CA list and the SSL policy is
checked for client authentication. The fingerprint comes from
CryptHashCertificate2(SHA256).
Examples and tests
- stream_server has new options --client-ca FILE,
--allow-fingerprint SHA256 and --allow-cn NAME (repeatable), and
--open for an open server. Without them it refuses to start. It
logs each client's CN and fingerprint. stream_client has --cert
FILE --key FILE.
- run_tests.sh makes a client CA and two client certificates and
adds stream_client_identity_logged, stream_no_client_cert_refused,
stream_wrong_client_cert_refused,
stream_server_refuses_without_auth_config and stream_open_server.
run_tests_win.sh runs the same checks; its CERT_DIR now also
needs client_ca.pem, client_ok.pem/.key and client_bad.pem/.key.
Compatibility
- Source compatible: all changes are new functions and a new
class. gxSSL, gxsTLSConnection and gxsTLSServer have new
members, so programs built against 7.3 must be rebuilt.
- Existing stream_server command lines must add --client-ca and
an allow option (or --open), and clients need --cert/--key.
- The Schannel code was written without a Windows compiler at hand
and needs a build and run_tests_win.sh run on Windows before
release. Depending on the Windows ClientAuthTrustMode setting,
Schannel may also check client certificates against the
machine's trusted roots during the handshake.
NOTE: a journal names the files it repairs. Recovering a journal that someone else wrote can write to any file the program may write, the same trust the program gives its database files. Keep journal files in a folder only the database owner can write.
Tests
- tests/journal_test has a security_fixes test for 1, 3 and 4.
- tests/fuzz has libFuzzer targets for damaged data files, index files and journals (fuzz_db.cpp, gen_seeds.cpp, build_fuzz.sh).
- tests/run_tests.sh: 49 checks passed on RHEL 10.2 in the default, 64-bit, 64-bit portable type and shared library builds, and under AddressSanitizer and UndefinedBehaviorSanitizer. Windows 11 (MSVC): the database examples, journal_test and damaged_files pass in 32-bit, 64-bit and 64-bit portable type builds.
The scan itself (tools, fuzzing statistics, reproducers) is described in DATAREEL_73_SECURITY_SCAN.md in the project notes.
DATABASE REPLICATION (added 11/07/2026, beta)
gxrepl keeps folders of object databases the same on two nodes over a gxStream TLS connection, TCP port 2073 (gxsDATA_PORT) by default, with an SSH tunnel as the fallback when the port is closed. See utils/gxrepl/README.md.
- gxdJournal::EnableShipLog(set_root, stream) / DisableShipLog(): each commit also appends the committed pages to a ship log (<set_root>/.gxrepl/log/<stream>/), under the journal's write lock, before the pages reach the files. Write-through mode only.
- gxdJournal::ApplyPages(jname, files): applies pages received from another node as one journal transaction (crash safe, then Recover).
- gxdrepl.h: gxdShipLog (writer), gxdShipLogReader, the record parsers and gxdReplHash.
- gxrepl.h: gxReplConfig, gxReplServer, gxReplClient and the local and remote sources and targets.
- utils/gxrepl: the gxrepl program and gxrepl_testwriter (tests).
- CMake option DATAREEL_ZLIB (ON): compresses replication messages with zlib when it is found.
No file format changes: a database written with the ship log is an ordinary database, and the log lives in its own folder. POSIX only.
11/08/2026 changes (replication protocol 2; both nodes must run the same version, a mismatch is refused in the hello):
- Databases only. gxrepl carries DataReel database files (.gxd, .btx) and the files a set names with "include" (a database's commit block, sources list, exports). The sender never offers another file, the receiver refuses one (SafePath: "not a database file"), deletes touch only database files, and hidden names are never copied. Flat files belong to the host's file sync (OSA: DRCM's rsync over ssh). Port 2073 carries database traffic only.
- Safe reads without a ship log: a database in a folder with a journal is read under gxdJournalReadLock; a published folder (no journal) is checked before and after each read, and a file that changed while it was read is read again (diff status 3), never sent torn.
- Power-off safety: a gxdJournal with the ship log enabled fdatasyncs each ship record before the commit's pages reach the files (unless its sync level is OFF). The ship log's small files, the copy's applied-position files and the status file are written with fsync, rename and a folder sync. The folders of files an apply creates are synced. A torn ship-log tail is cut back to the last whole record.
- A reconnect verifies only the files the ship-log streams cover; other database files get the size and mtime scan, and the full hash verify runs when full_verify_interval says so (or SIGHUP, once).
- The client writes its status file every 5 seconds during a pass.
Database object server (11/08/2026, phase 2; replication protocol 3):
- gxdbserver.h: gxDatabaseServer, one TLS listener on the database port shared by services (client certificates, handshakes off the accept loop, session limits); a session goes to the service that claims its first block.
- gxdbmux.h: gxdMuxSession, many databases over one connection: a channel per database with its own order, bounded queue, credit flow control and errors; one I/O thread per connection (non-blocking, so both sides can send at once); deficit round-robin between channels.
- gxrepl: the replication service of the server. The client opens a channel per set and runs each set on its own thread (the server has an applier thread per channel); a refused set ends only its channel. Durable ACK after a log apply, and the ACK floor in the ship log (acked/<copy>): an old segment goes only when every copy has it, up to the size cap.
- gxsTLSConnection::TakeBuffered().
- gxdbobject.h: gxObjectService, database objects over the network on the same server: [db NAME] databases, multiplex channels (service object, read or write) with ADD, REQUEST, CHANGE, DELETE, FIRST, NEXT; writes through the database journal; replicated copies are read-only and read under the apply journal lock (an apply holds it exclusively); 6.x style A/R clients on legacy_db. Examples: utils/dbserver/object_server.cpp, object_client.cpp.
Power-loss tests and fixes (11/09/2026, phase 2 step 5):
- utils/gxrepl/powerloss_shim.c: a test-only LD_PRELOAD library that keeps what a disk would still have after a power cut (a file's bytes when it is fsynced, a folder's entries when the folder is fsynced). test_gxrepl.py cuts the writer's node, the server's node or both at random moments, rebuilds the folders from that image only, and checks the copies, the retention floor and the object service.
- gxdFPTRCreate() now syncs the folder after it creates a file (POSIX). Before, a new database or journal could be lost in a power cut with every commit made to it, since commits synced only the file.
- The ship-log purge skips acked/<copy>.gxrtmp, which a crash in the middle of a floor write leaves; it was read as another copy's floor.
- gxrepl deletes now sync the folders they removed files from.
- The design document (docs/DATABASE_OBJECT_SERVER_DESIGN.md) section 11 specifies protocol 3: sessions, the multiplex frame, replication and objects on channels, the retention floor, and the status files.
Replication fixes from the 11/10 reviews (gxrepl-var-r3):
- The ship-log reader keeps two cursors (the end scan and the last read) and a sparse lsn -> offset index, so a Read() never rescans a segment. A Diff request's 4 MB / 100 ms read-lock budget counts the log read. Measured: the slowest writer commit during a full verify of a 256 MB live file was 204 ms at load 31 (2078 ms with the old whole-file lock).
- A ship-log record bigger than max_message (an osa_ingest rebuild writes one of 500 MB) is never sent or even read: READLOG status 2, the copy's position is reset and the stream's files are resynced in pieces.
- commit_block copies: the copy's commit block is marked odd (protocol op 15, MARKGEN) before a unit's files change and stays odd until a whole commit is in; "gxrepl torn" / "gxrepl.sh promote-check" lists torn copies (exit 1) so a fail over does not promote them. A heartbeat write to the commit block is not a change. Measured: an unlocked 8 MB writer at 5 commits/s and a 434 MB folder with a commit every 2 s both keep copying whole commits.
- Stream purge: an acked/<copy> file that cannot be read keeps the stream even when another copy ACKed it; a stream whose one segment every copy applied starts a new segment when its writer opens, so retention can trim it. ship_log_max_total is in bytes.
- "gxrepl version" names the git head of the DataReel sources (+dirty) and the build time (gxrepl_version.cmake), or "unknown".
Ship-log volume and whole copies (11/10, gxrepl-var-r4 / r4d):
- Volume. Commit records are zlib-compressed (type 4, gxdShipCommitZ: raw size, a CRC-32 of the raw payload checked after inflate, zlib) when that is smaller; readers take both types (gxdParseShipCommitRecord), so older logs still read. GXDSHIP_COMPRESS=0 turns it off. Derived indexes (per set "derived = GLOB") are left out of the records at the writer (gxdShipLog::SetExclude; OSA: osa_ingest --ship-log-derived) and rebuilt on the copy ("derived_rebuild = CMD {dir} [{lsn}]", "derived_delay"). Measured on OSA's realtime day, per 50-line commit: 1,477,740 bytes of pages, 179 KB compressed, 8.9 KB with both (167x less): about 9 KB per commit, about 100 MB a day for the realtime set instead of 15-20 GB shipped as pages. No measurable CPU.
- Limits. A record counts against max_message by its stored size, or its inflated size when that is bigger; keep max_message above the largest record (a bigger one is never sent: the copy resyncs its files, and at 256 KB in the tests the copy fell 68 records behind on such resyncs). AppendCommit refuses a record over 1 GB raw (the size is a u32): it logs a gap and the copy verifies the stream.
- The commit block travels in the record. gxdShipLog::SetCommitBlock() gives the writer's commit block (as it is once the commit lands) to the next commit record, as its last file; the copy applies the pages, the commit block and the unit's seal "log G L S" (generation, lsn, stream) in one apply.jnl transaction. A record that changes a unit without its commit block seals it "copying-log" (torn until a record carries the block); a fill out of step with the copy's stream seals it "copying" until the commit block, sent after the folder's files, lands. The source serves a ship-log folder's commit block from its log, never its file, and never one older than a later record that changed the folder.
- "gxrepl torn" (promote-check) requires, for a ship-log unit, the seal's generation = the commit block's and the seal's lsn = the stream's applied lsn, and for derived indexes a stamp (<folder>/derived.stamp: "gen G lsn L records N keys K") at that generation and lsn with keys = records. Old-format logs (no commit block) apply but are UNSEALED.
- Busy days (r4e, 11/11): missing or stale derived indexes are a warning ("INDEXES", exit 0), not torn: a take over's writer rebuilds them; a rebuild that failed stays torn. "derived_busy_rebuild" (default 900 s) rebuilds a folder that is never quiet for derived_delay anyway, under the apply lock.