NationalSecurityAgency/ghidra · error · LSHException
Trying to insert on read-only database
Error message
Trying to insert on read-only database
What it means
fdbDatabaseInsert first checks info.readonly; if the database was opened read-only it throws LSHException("Trying to insert on read-only database") before any insert is attempted.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java:3041
* @param request is command parameters
*/
private void fdbPrewarm(PrewarmRequest request) {
final ResponsePrewarm response = request.prewarmresponse;
response.operationSupported = false;
}
/**
* Entry point for the Elasticsearch version of InsertRequest command:
* Insert new functions and executables into the database.
* @param query is command parameters
* @throws LSHException if the command is misconfigured
* @throws ElasticException for communication problems with the server
* @throws DatabaseNonFatalException if everything is already inserted
*/
private void fdbDatabaseInsert(InsertRequest query)
throws LSHException, ElasticException, DatabaseNonFatalException {
if (info.readonly) {
throw new LSHException("Trying to insert on read-only database");
}
if (FunctionDatabase.checkSettingsForInsert(query.manage, info)) { // Check if settings are valid and is this is first insert
info.major = query.manage.getMajorVersion();
info.minor = query.manage.getMinorVersion();
info.settings = query.manage.getSettings();
writeBasicInfo(0, 0); // Save off the settings associated with this first insert
}
ResponseInsert response = query.insertresponse;
if ((query.repo_override != null) && (query.repo_override.length() != 0)) {
query.manage.overrideRepository(query.repo_override, query.path_override);
}
// Insert each executable in turn
boolean newExecutable = false;
for (ExecutableRecord erec : query.manage.getExecutableRecordSet()) {
if (erec.isLibrary()) {
insertLibrary(query.manage, erec);
}
else if (insertExe(query.manage, erec)) {View on GitHub (pinned to d5f144c24d)
Solutions
- Open the database in read/write mode.
- Use write-enabled credentials / a write-capable URL.
- Perform inserts against the primary cluster, not a read replica.
Example fix
// before // opened readonly: db.initializeReadOnly(url); db.insert(req); -> LSHException // after db.initialize(url); // read/write db.insert(req);
Defensive patterns
Strategy: validation
Validate before calling
if (db.getInfo().readonly) {
throw new IllegalStateException("Database is read-only; cannot insert");
} Type guard
boolean writable = !db.getInfo().readonly;
Prevention
- Open a separate read/write handle for ingest paths.
- Gate ingest commands on a writable-connection check.
When it happens
Trigger: Issuing an InsertRequest against a connection/database that was opened in read-only mode.
Common situations: Connecting with a read-only URL or read-only credential to perform ingest; pointing at a read replica; forgot to set write mode.
Related errors
- Trying to insert on read-only database
- Could not commit self-score: {ex.getMessage()}
- Could not create database:
- LSHException fatal error
- Already inserted
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/9ce598e8cd11ff6f.
Report an issue: GitHub.