Skip to content

v2026.11.23 — The DuckDB transaction is the SAP LUW, and a faster proto backend

Choose a tag to compare

@jrosskopf jrosskopf released this 23 Nov 15:29
· 3 commits to master since this release
ea3cc9d

BEGIN … COMMIT now spans one SAP session per secret and ends in BAPI_TRANSACTION_COMMIT, so write BAPIs can be
committed from SQL. An ODP read no longer risks putting values in the wrong column when another read runs in the
same process. And the proto backend (SET erpl_rfc_backend = 'proto'; SAP's NW RFC SDK is still the default) reads
large tables as fast as SAP's library: on a 297,000-row sap_read_table('DD04T') it now takes no more wall time and
less CPU.

Added

  • [rfc] [bics] [odp] [ape] The DuckDB transaction is the SAP LUW (#244). Between BEGIN and COMMIT/ROLLBACK, every
    erpl call to SAP (sap_rfc_invoke, sap_read_table, the describe/show functions, PRAGMA sap_rfc_ping,
    ATTACHed tables) runs on one RFC session per secret. COMMIT calls BAPI_TRANSACTION_COMMIT with
    WAIT = 'X' on it and fails with SAP's message if RETURN reports E/A; ROLLBACK — also after a failed
    statement, or when the connection closes with the transaction open — calls BAPI_TRANSACTION_ROLLBACK. Write
    BAPIs that post through the update task can now be committed from SQL. Autocommit statements are unchanged
    (a connection per call, no commit). Inside a transaction sap_read_table reads serially on that session.
    SAP commits before DuckDB does; a rejected SAP commit aborts the DuckDB transaction, but a DuckDB commit that
    fails after SAP committed cannot undo the SAP changes, so DuckDB writes and SAP writes are not atomic together.
    A commit whose call fails reports its outcome as unknown (check SM13 before retrying); a session lost to a
    communication failure or short dump fails the rest of the transaction; a statement prepared in a transaction
    and executed after it fails cleanly ("prepare the statement again"); a prepared COMMIT (a client's
    commit()) commits SAP first as well. A partial commit across several secrets names the sessions that stay
    committed; a DuckDB commit that fails after SAP committed is reported on the next erpl call.
    [bics] [odp] [ape] take part as well: every sap_bics_*, sap_odp_* and sap_ape_* function and pragma
    runs on the transaction's session, except the ODP extraction calls (RODPS_REPL_ODP_OPEN/_FETCH/_CLOSE),
    which stay on their own, parallel connections, and the APE read graphs of sap_ape_read_full/_delta, which
    stay on their own because the engine's commits would otherwise commit the transaction's pending writes
    (measured on A4H); ODP and APE still commit their own extraction progress on the SAP side.

Fixed

  • [odp] ODP reads in one process no longer share a tag dictionary (#249). A BXML document numbers its own
    tags, and the parser kept the id-to-name map process-wide, so a second read -- a parallel scan thread, or the
    next sap_odp_read_*, even with threads = 1 -- could redefine an id, and the first read's later values went
    to the wrong column or to none, with no error. It was also a data race on that map across scan threads. Each
    document now has its own dictionary, carried across fetch chunks with the rest of the parser state.
  • [odp] A full ODP read under load no longer fails intermittently with the XML parse error Next char ffff
    (#247): the inflate stream of a package could end early. [ape] sap_ape_read_full's test no longer depends
    on the exact row count of the source (#248).

Faster (proto backend)

  • [rfc] Parallel table reads no longer queue on one lock. DuckDB reads a result with several threads, and
    every cell read took the same exclusive lock in the shim: 8 million acquisitions on a 297,000-row read, 2.6
    million of them waiting. Cell reads now share it. DD04T through erpl: 10.4 s → 8.1–8.4 s against SAP's library's
    7.7–8.0 s, system time 18.5 s → 4.2–4.7 s.
  • [rfc] Text cells are converted without allocating. Each cell's conversion to UTF-8 grew its output one
    character at a time (2.8 million reallocations on that read, against 7 thousand in SAP's library); ASCII text is
    now copied in one pass. The same read then takes 6.4 s against SAP's library's 7.0 s, and 12.7 s of user CPU
    against 13.1 s.
  • [rfc] Background RFC units (bgRFC) are accepted by the server and their states are read correctly; this
    does not change any erpl SQL function.

erpl-proto 6548f70 → 35be92c.

Local gates on DuckDB v1.5.6 against a4h (kernel 816), on both backends (SAP NW RFC SDK and proto): rfc 36/36, odp 27/27, bics 183/183. Full-matrix CI (DuckDB v1.5.6 and v2.0.1, including the offline LUW unit tests): run 45179372820, 26/26 jobs green.