This is the multi-page printable view of this section.
LOLOR
- 1: Installing and Configuring lolor
- 2: lolor Release Notes
- 3: Using lolor
- 4: Using pg_upgrade with lolor
Upstream reference for LOLOR 1.3.0-dev. Mimus 19.0.1 integrates Spock 5.0.15. Compatibility of LOLOR with Mimus is unverified.
The English source is 1.3.0 development snapshot; latest stable tag v1.2.3, pinned at 1548836b0df0. A Chinese edition of this snapshot is available. Check versions and sources before deploying.
On a normal drop, the event trigger checks replication and stored objects, then calls lolor.disable() if needed to restore the native function names. The object-access hook rejects removal if those names are still parked. Migrate the objects back to native storage before dropping the extension. Pinned implementation
lolor is an extension that makes Postgres-style large objects compatible with logical Replication.
Postgres supports large objects as related chunks as described in the pg_largeobject table. Large objects provide stream-style access to user data stored in a special large-object structure in the catalog. Large objects stored in catalog tables require special handling during replication; the lolor extension allows for the storage of large objects in non-catalog tables, aiding in replication of large objects.
lolor creates and manages large object related tables in the lolor schema:
Postgres large objects allow you to store large files within the database. Each large object is recognised by an OID that is assigned at the time of its creation. lolor stores objects in smaller segments within a separate system table and generates associated OIDs for large objects that are distinct from those of native large objects.
Use of the lolor extension requires Postgres 16 or newer.
Migrating large objects
Migration is a manual step in both directions: you decide when to move existing large objects into lolor storage, and you move them back before dropping the extension. Dropping the extension never moves data: it is refused while any object remains in lolor storage.
Native to lolor (manual)
If your database already contains native Postgres large objects, call
migrate_from_native() after enabling the extension. The migration preserves
original OIDs, owners, ACLs, and data, so existing application references remain
valid.
The function returns the number of large objects migrated. It is safe to call when there are no native large objects. This step is intentionally not automatic: it requires superuser privileges and should be performed during a maintenance window.
Lolor to native (before DROP EXTENSION)
Move the large objects back to native Postgres storage, then drop the extension:
Both paths preserve OIDs, owners, ACLs, comments and data, and copy pages verbatim so sparse large objects stay sparse.
A helper supports verifying a migration across nodes:
An object access hook refuses to remove the extension while it is enabled or
while any object remains in lolor storage, on every path that reaches it
(DROP EXTENSION, DROP SCHEMA lolor CASCADE, DROP OWNED BY). The drop
itself only puts the native pg_catalog.lo_* names back. To discard whatever
is in lolor storage instead, a superuser can set lolor.allow_unsafe_drop = on
for the session that runs the drop. It skips every check, and the drop then
does not restore the native function names either, so run lolor.disable()
first if lolor is enabled. While lolor is enabled, a normal drop renames the
native functions back, so it has the same requirements as lolor.disable():
no other session connected to the database, and a client session. A disabled
lolor renames nothing, and the drop has no such requirement.
lolor.enable() and lolor.disable() refuse while
any other session is connected to the database, and refuse to run from
anything but a client session. Reconnect client sessions after enable() or
disable(): libpq caches the large object function OIDs per connection.
Two helpers find and repair objects whose roles have been dropped:
When the spock extension is installed, both migration functions run under
spock.repair_mode(), so the row-shuffling migration DML is not replicated
to other nodes. This is essential for migrate_to_native(): its deletes from
the lolor tables would otherwise replicate while the native re-creation stayed
local, destroying large objects on the other nodes.
Even with spock, migration is refused if a non-spock logical replication slot
(e.g. pgoutput, wal2json) exists, since repair mode only suppresses spock’s
own output plugin and those consumers would still decode the migration DML:
migrate_to_native() raises an ERROR, while migrate_from_native() warns and
returns -1 without doing anything. Drop the offending slots before migrating.
Without spock, the migration DML cannot be excluded from logical decoding, so
both functions refuse to migrate while logical replication slots exist in the
database: migrate_from_native() raises a WARNING and returns -1 without
doing anything (0 is reserved for “nothing to migrate”), while
migrate_to_native() raises an ERROR. Drop all logical replication slots before
migrating; merely disabling a subscription is not sufficient, since its slot
retains the changes and delivers them when replication resumes.
Dropping the extension
In a replicated cluster the lolor tables are published, subscribed, or both, and the drop is refused while any of that is still true: the drop itself would succeed, but the other side would keep sending or expecting rows for tables this node no longer has. Unwind replication first, in this order:
Stop creating and changing large objects on every node, and let replication drain. Then confirm the nodes agree:
Stop publishing the tables. With Spock, remove them from the replication set on every provider node that publishes them:
With native logical replication, drop them from the publication instead:
A publication created
FOR TABLES IN SCHEMA lolordrops them withALTER PUBLICATION mypub DROP TABLES IN SCHEMA lolor. AFOR ALL TABLESpublication publishes them for as long as it exists: drop it, or recreate it with an explicit table list.Stop subscribing to them. A node that synchronized the tables when its spock subscription was created still counts them as replicated; refresh the subscription on that node so it forgets tables that are no longer in the provider’s replication sets:
A native subscription is refreshed with:
From here no node publishes the tables and no subscription expects changes for them, so the order of the per-node steps below does not matter.
Migrate the data out on every node, connecting to each node directly; with spock the migration runs in repair mode and is not replicated:
The migration refuses while a logical replication slot of any plugin other than spock’s exists in the database, and a native subscription keeps its slot on the publisher even when refreshed or disabled. Drop the native subscriptions that point at the node, which removes their slots, before migrating there.
Drop the extension on each node, connecting to each node directly, with no other client session connected to the database:
Without replication there is a single node: stop large object use, run
lolor.migrate_to_native(), and drop the extension, with the same
single-session requirement while lolor is enabled.
Limitations
- Native Postgres large object functionality cannot be used while you are using the lolor extension.
- lolor does not support the following statements against objects held in lolor storage:
ALTER LARGE OBJECT,GRANT ON LARGE OBJECT,COMMENT ON LARGE OBJECT, andREVOKE ON LARGE OBJECT. Owners, ACLs and comments set while an object was in native storage are preserved across migration in both directions. lolor.enable(),lolor.disable(), the migration functions,CREATE EXTENSION lolor, and dropping the extension while lolor is enabled, refuse while any other session is connected to the database, the same rule asALTER DATABASE ... RENAME: a renamed function keeps its OID, so a session that already resolved thelo_*functions keeps calling the previous implementation, and the row movement cannot be made atomic for other backends either. The calling session must reconnect afterenable()ordisable(). They also refuse to run from anything but a client session, so replicated DDL cannot drive them from an apply worker. Only client sessions count: background workers such as replication apply workers do not call thelo_*functions by name. To count reliably, each of these operations takes an exclusive lock on the database first, so a new connection to it waits until the operation’s transaction ends. In single-user mode they run without the session check.- The loaded library and the installed extension must be the same version for
lolor.enable(),lolor.disable(), the migration functions,lolor.check_orphans(),lolor.fix_orphans()and dropping the extension. After installing new library files, runALTER EXTENSION lolor UPDATEin each database before using them; until then they refuse and name both versions. - Objects in lolor storage are rows in ordinary tables and so cannot participate in
pg_shdepend.DROP ROLE,DROP OWNED BYandREASSIGN OWNED BYdo not see them: a role that owns them or appears in their ACL can be dropped without a warning, andREASSIGN OWNED/DROP OWNEDleave them untouched. Before dropping a role, runREASSIGN OWNED BYorDROP OWNED BYin each database that has lolor, thenDROP ROLE. For the role that owns the extension useREASSIGN OWNED BY:DROP OWNED BYwould remove the extension too, and is refused while any object remains in lolor storage. Afterwards runlolor.check_orphans()in each such database and repair anything it reports withlolor.fix_orphans(new_owner);lolor.migrate_to_native()refuses while orphans exist. - Dropping lolor is refused while
lolor.pg_largeobject,lolor.pg_largeobject_metadataorlolor.pg_largeobject_descriptionis in a spock replication set, a publication or a subscription on this node, or was synchronized to this node through a spock subscription, whichever way the drop is spelled. The drop itself would succeed; what breaks is replication afterwards, since the other side keeps sending rows for a table this node no longer has. Remove the tables from the replication set, publication or subscription first, then migrate the objects out and drop. The refusal is enforced when the tables are deleted, not only by the event trigger, so disabling event triggers does not get around it. A spock subscriber knows the tables as replicated only from their initial synchronization; a table added to a replication set later is not seen by the check on that node. The step-by-step order is in Dropping the extension. - Role OIDs come from a cluster-wide counter that wraps around, so a new role can receive a dropped role’s OID and silently become the owner or grantee of that role’s orphaned objects. This cannot be detected after the fact, which is another reason to run
lolor.check_orphans()promptly after dropping roles. - Large object migration is node-local. Native large objects live in
pg_catalog.pg_largeobject, which is never replicated, so each node holds an independent set andmigrate_from_native()migrates only the local node’s objects; with spock installed, the migration DML runs in repair mode and is not replicated. Run the migration on every node that holds native large objects, connecting to each node directly. It refuses to run inside an apply worker, so sending it through DDL replication fails on every subscriber. Migrated objects keep their original native OIDs, which are not node-encoded: if different nodes hold different objects under the same OID, the nodes’ lolor contents will diverge and later replicated changes to those objects can conflict. Newly created large objects are collision-free, since new OIDs are node-encoded vialolor.nodeand checked against existing rows. To make that hazard an error rather than silent divergence, collect the other nodes’ OIDs withlolor.native_lo_oids()and pass them in:SELECT lolor.migrate_from_native(peer_oids => ARRAY[...])refuses when any of them collide. After migrating every node, comparelolor.digest()across nodes to confirm they converged.
Continue reading
Upstream source · 1548836b0df0 · Copyright (c) 2024–2026, pgEdge, Inc. PostgreSQL License.
1 - Installing and Configuring lolor
Upstream reference for LOLOR 1.3.0-dev. Mimus 19.0.1 integrates Spock 5.0.15. Compatibility of LOLOR with Mimus is unverified.
lolor is supported on Postgres versions 16 and later.
lolor ships with pgEdge Distributed Postgres and pgEdge Enterprise Postgres, so a pgEdge deployment provides the extension for you. The Control Plane installs the lolor package on each node as part of standard cluster setup.
If you manage Postgres yourself, you can compile and install the extension from the source code, following the same guidelines as any other Postgres extension built with PGXS. Make sure that your PATH environment variable includes the directory where pg_config (under your PostgreSQL installation) is located.
lolor must be loaded at server start. Add it to shared_preload_libraries in postgresql.conf and restart; CREATE EXTENSION lolor, LOAD 'lolor' and any call that reaches one of lolor’s functions fail with lolor must be loaded via "shared_preload_libraries" when the library was loaded on demand; the native pg_catalog.lo_* functions are not affected while lolor is not installed or is disabled. The guard that protects large objects when the extension is dropped is an object access hook, which is only in place in every backend when the library is preloaded.
Then connect to your Postgres database and create the extension with the command:
Configuring lolor
You must set the lolor.node parameter on each node in your replication cluster before using the extension. The value can be from 1 to 15 (0 means unset); it is encoded in the four low bits of every large object OID lolor generates, so each node must use a different value.
You can also change the search_path to pick large object related tables from the lolor schema:
lolor renames any existing methods in pg_catalog.lo_* to pg_catalog.lo_*_orig, and new versions of these methods are introduced. If you remove the extension, the renamed pg_catalog.lo_*_orig functions are restored to their initial names.
When you replicate large objects with Spock, the tables pg_largeobject, pg_largeobject_metadata and pg_largeobject_description must belong to your replication set. The third table holds the comment of each object that was migrated from native storage; without it, a lo_unlink() leaves the comment behind on the other nodes, and a node that is added or resynchronized later does not receive the comments. Connect to the lolor database and add them with spock.repset_add_table:
Upstream source · 1548836b0df0 · Copyright (c) 2024–2026, pgEdge, Inc. PostgreSQL License.
2 - lolor Release Notes
Upstream reference for LOLOR 1.3.0-dev. Mimus 19.0.1 integrates Spock 5.0.15. Compatibility of LOLOR with Mimus is unverified.
lolor 1.3.0
These notes describe pinned main development. The latest stable tag checked on November 21, 2026 remains v1.2.3.
On a normal drop, the event trigger checks replication and stored objects, then calls lolor.disable() if needed to restore the native function names. The object-access hook rejects removal if those names are still parked. Migrate the objects back to native storage before dropping the extension. Pinned implementation
- Add bidirectional large object migration between native PostgreSQL and lolor storage, implemented as a direct relation-to-relation copy in C (
lolor.migrate_storage()) rather than a loop through the large object API:lolor.migrate_from_native(peer_oids oid[] DEFAULT NULL)moves native large objects into lolor storage. It is a manual step afterCREATE EXTENSION lolor, requires superuser, and returns the number of objects moved or -1 if the migration was refused.lolor.migrate_to_native()moves them back, whether or not lolor is enabled. It is a manual step before dropping the extension; the drop is refused while any object remains in lolor storage and no longer migrates anything itself.- Both directions preserve OIDs, owners, ACLs, comments and the exact page layout, so sparse objects stay sparse. Ownership and ACLs are recorded in
pg_shdependon the way back, soDROP ROLE,REASSIGN OWNEDandDROP OWNEDsee the objects again. Comments are parked inlolor.pg_largeobject_descriptionwhile an object is in lolor storage. Native objects are removed with the same bookkeeping asDROP(dependencies, comments and labels), but without the per-object locksDROPtakes, so a database with more large objects than the lock table can hold is migrated without raisingmax_locks_per_transaction. - Storage layouts are verified against the running server at migration time. Security labels, which lolor storage cannot represent, cause
migrate_from_native()to refuse. OID conflicts are reported with the conflicting OIDs. - Migration holds
ShareRowExclusiveLockon both stores until commit. Ordinary large object access takesRowExclusiveLock, which does not conflict with itself, so a concurrentlo_write()could otherwise be lost silently. Opposing migrations take their locks in a fixed order and cannot deadlock. - Both migration functions refuse while any other session is connected to the database, and refuse to run from anything but a client session.
- With spock installed, both functions run under
spock.repair_mode(). If a logical slot spock cannot suppress exists, a non-spock slot or any slot when spock is absent, they refuse rather than let subscribers decode the migration as row changes. - Migration is node-local: native large objects are never replicated, so run the migration on each node by connecting to it directly. Do not send it through DDL replication, which would run it inside every subscriber’s apply worker. Native OIDs are not node-encoded, so pass the other nodes’ OIDs (from
lolor.native_lo_oids()) aspeer_oidsto turn a cross-node collision into a refusal, and comparelolor.digest()across nodes afterwards. migrate_to_native()refuses with a clear error while any object refers to a dropped role, instead of failing part-way with “role N was concurrently dropped”; remove those objects withlo_unlink()and retry.
- New helpers
lolor.digest()andlolor.native_lo_oids()for cross-node checks after a node-local migration. - New helpers
lolor.check_orphans()andlolor.fix_orphans(new_owner)for objects whose owner, grantee or grantor has been dropped. Objects in lolor storage cannot participate inpg_shdepend, soDROP ROLEdoes not notice them;check_orphans()lists them and which reference is dangling, andfix_orphans()reassigns dead owners, replacing them in the ACL asREASSIGN OWNEDwould so that grants they made survive, and drops entries that still name a missing role. - Server-side large-object file permissions. Versions 1.0 through 1.2.2 granted excessive default execution rights on replacement file-import and export functions. Use the corrected extension SQL and verify function privileges after upgrade. Review which roles actually need server-side file access.
- The extension is no longer marked
trusted. Installing lolor renames functions inpg_catalogfor the whole database, which a non-superuser should not be able to do. - Fixed
DROP ROLEfailing with “unrecognized object class”. Creating a large object recorded apg_shdependrow whoseclassIdwas the OID oflolor.pg_largeobject, an ordinary table rather than a catalog. Any role that had created a large object became undroppable, and the rows were never cleaned up becauseinv_drop()deleted withPERFORM_DELETION_SKIP_ORIGINAL. lolor no longer records these rows, and the upgrade removes the ones already present.- The cleanup is per database, so
ALTER EXTENSION lolor UPDATEmust be run in every database that has lolor. Until it is,DROP ROLEanywhere in the cluster keeps reporting “owner of objects in database X”. - A database that ran
DROP EXTENSION loloron an earlier version still has the rows, now pointing at a table that no longer exists, and no upgrade script will run there. Clean it by hand as superuser in that database: find the stale class OIDs withSELECT DISTINCT classid FROM pg_shdepend WHERE dbid = (SELECT oid FROM pg_database WHERE datname = current_database()) AND classid NOT IN (SELECT oid FROM pg_class), thenDELETE FROM pg_shdepend WHERE dbid = <that dbid> AND classid IN (<those OIDs>).
- The cleanup is per database, so
- lolor must now be listed in
shared_preload_libraries. Loading it on demand is refused:CREATE EXTENSION lolor,LOAD 'lolor'and any call that reaches one of lolor’s functions fail withlolor must be loaded via "shared_preload_libraries"; the nativepg_catalog.lo_*functions are not affected while lolor is not installed or is disabled. The drop guard below is an object access hook, which is only present in every backend and worker when the library is preloaded, and a missing or broken library now fails at server start rather than at the firstlo_open(). Upgrade in this order: install the new library files, addlolortoshared_preload_libraries, restart, then runALTER EXTENSION lolor UPDATEin each database. Between the file install and the restart, any session that loads the new library on demand gets that error, so restart promptly. - Removing the extension is guarded by an object access hook.
DROP EXTENSION,DROP SCHEMA lolor CASCADE,DROP OWNED BYand any other path that reaches the extension are refused while lolor is enabled or while any object remains in lolor storage, checked in the catalog at the moment of deletion from whichever backend performs it. The drop no longer migrates the objects out itself: runlolor.migrate_to_native()first. The event trigger only puts the nativepg_catalog.lo_*names back. The new superuser settinglolor.allow_unsafe_dropskips both checks and discards the contents of lolor storage. Because the drop renames the native functions back, it has the same requirements aslolor.disable(): no other session connected to the database, and a client session. - Dropping lolor is refused while its tables are in a spock replication set, a publication on this node, including one created
FOR ALL TABLESorFOR TABLES IN SCHEMA lolor, or a subscription on this node, or were synchronized to it through a spock subscription. The drop would succeed and replication would break afterwards: the other side keeps sending rows for a table this node no longer has, and a subscription removed byDROP OWNED BYleaves its slot behind. The error names the memberships; remove the tables from them first. The check is enforced when the tables are deleted, so it holds with event triggers disabled. lolor.enable()andlolor.disable()refuse to run from anything but a client session, so replicated DDL cannot execute them inside an apply worker, where a refusal would leave that node’s replication retrying forever.CREATE EXTENSION lolorhas the same requirements aslolor.enable(), since the install script renames the native functions the same way: no other session connected to the database, and a client session.lolor.enable(),lolor.disable()andlolor.is_enabled()now probe exact function signatures inpg_catalog. They previously matched onpronameacross every schema, so any user withCREATEon any schema could define a function namedlolor_lo_openand wedge lolor into a permanent “inconsistent state” that also blockedDROP EXTENSION. Both now emit a notice that client sessions must reconnect, since libpq caches the large object function OIDs per connection, and refuse while any other session is connected to the database, since a renamed function keeps its OID and other sessions cannot be made to see the switch.- The session check behind
lolor.enable(),lolor.disable(), the migration functions and the drop is done in C and takes an exclusive lock on the database before counting, so a session connecting at the same moment either is counted or waits until the operation’s transaction ends. Previously it was a snapshot ofpg_stat_activityand could miss such a session. Single-user mode is no longer refused. lolor.enable(),lolor.disable(), the migration functions,lolor.check_orphans(),lolor.fix_orphans()and dropping the extension refuse while the loaded library and the installed extension are different versions. A drop with new library files and an older installed extension would otherwise run that version’sdisable(), which still has the unqualified function lookups fixed in this release. RunALTER EXTENSION lolor UPDATEfirst.- Fixed the
lolor.nodeupper bound. The GUC accepted 0..16 while a generated OID reserves four bits for the node id, so node 16 did not fit: the node field of every OID it generated read back as 0. The bound is now derived from the encoding (LOLOR_MAX_NODE_ID), giving 0..15. If you havelolor.node = 16configured, the server still starts but logs16 is outside the valid range for parameter "lolor.node" (0 .. 15)and falls back to 0, which is the node id it was effectively using already. Set it to a value in 0..15, and check for OID collisions against whichever node is genuinely 0. - Expanded test coverage: TAP tests for dump/restore, streaming and logical replication, standby promotion, the drop paths, migration fidelity and locking, and cross-node OID collisions; regression tests for
lo_lseek,lo_tell,lo_truncate, the 64-bit interface, sparse objects, comment round trips,pg_shdependrestoration, permission enforcement, the orphan helpers and name squatting. The regression suite runs on its own preloaded instance. - Security hardening: addressed Codacy/Flawfinder warnings.
lolor 1.2.3
- Add support for PostgreSQL 19
- Add in-repo release workflow and RPM/DEB packaging
- Improve CI: build the test cluster from source, add PostgreSQL 19 to the test matrix, and bound test run time
lolor 1.2.2
- Fix lolor upgrades
- Fix issues with pg_upgrade. Note that this fixes upgrades with pg_upgrade going forward.
ALTER EXTENSION UPDATEfor upgrading the extension itself works, so if wanting to run pg_upgrade, first update your extension to 1.2.2, then run pg_upgrade - Address CVEs CVE-2022-26520, GHSA-673j-qm5f-xpv8
- PATH updated to match native Postgres packaging layout
- Make table OID caching safer
Upstream source · 1548836b0df0 · Copyright (c) 2024–2026, pgEdge, Inc. PostgreSQL License.
3 - Using lolor
Upstream reference for LOLOR 1.3.0-dev. Mimus 19.0.1 integrates Spock 5.0.15. Compatibility of LOLOR with Mimus is unverified.
The following command examples demonstrate using lolor:
Upstream source · 1548836b0df0 · Copyright (c) 2024–2026, pgEdge, Inc. PostgreSQL License.
4 - Using pg_upgrade with lolor
Upstream reference for LOLOR 1.3.0-dev. Mimus 19.0.1 integrates Spock 5.0.15. Compatibility of LOLOR with Mimus is unverified.
The pg_upgrade utility is used for upgrading Postgres versions.
You can use pg_upgrade with the lolor extension installed provided that you are using lolor version 1.2.2 or later. If you are using an older version of lolor, you will need to upgrade the extension first.
Both clusters must list lolor in shared_preload_libraries; without it the new cluster cannot load lolor’s library, so restoring the extension fails.
Before running pg_upgrade, you must disable lolor. After executing pg_upgrade, you can enable lolor. Use psql or another client to disable lolor:
Next, execute the upgrade. A sample pg_upgrade command appears below:
Then, use psql to enable lolor:
Reconnect any client sessions afterwards. lolor.enable() and
lolor.disable() change which function OID owns each pg_catalog.lo_* name,
and libpq resolves those OIDs once per connection and caches them for the life
of the connection. A session that used a large object before the switch would
otherwise keep calling the previous implementation.
Upstream source · 1548836b0df0 · Copyright (c) 2024–2026, pgEdge, Inc. PostgreSQL License.