Repository navigation
Description
export-ldif, verify-index and backendstat open a backend read-only when the server is not already holding it open. JDBCStorage refuses to hand out a write transaction in that mode, and RootContainer.open() always asks for one, so all three tools fail on a JDBC backend before they read anything.
Surfaced while reviewing #867; it does not belong to that PR.
The path
The three tools take the read-only handle:
// opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java:950
RootContainer getReadOnlyRootContainer() throws ConfigException, InitializationException
{
return newRootContainer(AccessMode.READ_ONLY);
}reached from exportLDIF (:621), verifyBackend (:728) and BackendStat.java:917, each guarded by mustOpenRootContainer(), which is simply rootContainer == null (:647-650).
RootContainer.open() then opens the storage in that mode and immediately asks for a write transaction, because that is where the compressed schema and the entry containers are opened:
// opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/RootContainer.java:130
void open(final AccessMode accessMode) throws StorageRuntimeException, ConfigException
{
storage.open(accessMode);
storage.write(new WriteOperation()
{
public void run(WriteableTransaction txn) throws Exception
{
compressedSchema = new PersistentCompressedSchema(serverContext, storage, txn, accessMode);
openAndRegisterEntryContainers(txn, config.getBaseDN(), accessMode);
}
});and JDBCStorage rejects that transaction outright:
// opendj-server-legacy/src/main/java/org/opends/server/backends/jdbc/JDBCStorage.java:402
private final class WriteableTransactionTransactionImpl extends ReadableTransactionImpl implements WriteableTransaction {
public WriteableTransactionTransactionImpl(Connection con) {
super(con);
if (!accessMode.isWriteable()) {
throw new ReadOnlyStorageException();
}Scope
Only the case where the backend is not already open, i.e. the offline tools — a stopped server, or a disabled backend. The online task path reuses the root container the running server holds, which is READ_WRITE (BackendImpl.java:200), so an online export-ldif task works.
How PDB does it
PDBStorage does not refuse the transaction; in read-only mode it wraps the storage and rejects only the mutating operations, plus tree creation:
// opendj-server-legacy/src/main/java/org/opends/server/backends/pdb/PDBStorage.java:692
public void openTree(TreeName treeName, boolean createOnDemand)
{
if (createOnDemand)
{
throw new ReadOnlyStorageException();
}
...
}
// :727, :733, :739, :745 - deleteTree, put, update, delete all throwwhich is exactly what RootContainer.open() needs: a transaction that may open existing trees and nothing else.
Suggested fix
Mirror that shape in JDBCStorage: let the write transaction be constructed in read-only mode and throw ReadOnlyStorageException from put, update, delete, deleteTree and from openTree(..., true) instead. The mode check moves from the constructor to the operations, and the three tools start working without any change to RootContainer.
Activity
[OpenIdentityPlatform#874] Grant the offline tools a read-only JDBC t…
[#874] Grant the offline tools a read-only JDBC transaction instead o…
Merge remote-tracking branch 'origin/master' into issues/888-jdbc-tre…
Merge remote-tracking branch 'origin/master' into issues/877-jdbc-sta…
[OpenIdentityPlatform#877] Refuse an import of a read-only storage ag…