cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

WRITE plugin throws 'Neo4jError: Writing in read access mode not allowed' registering trxListener

I'm trying to use TransactionEventListener in neo4j. There don't seem to be any lifecycle hooks for plugins, so I figure the only way to do it is to have a plugin procedure do it. However, trying to do that gives me this error:

Neo4jError: Writing in read access mode not allowed. Attempted write to internal graph 1 (system)

The plugin uses write mode, even if I'm not actually writing anything to the database; I'm just registering that TransactionEventListener, although that could indeed lead to writes later on. Still, I've got Write mode.

Here's my procedure:

@Procedure(name = "setTransactionListener", mode = Mode.WRITE)
public Stream<BuiltInProcedures.NodeResult> setTaxonomy(
        @Name("taxonomy") Map<String, Map<String, Object>[]> taxonomy
) {
    var managementService = new DatabaseManagementServiceBuilder(Path.of(".")).build();
    var listener = new ValidationTransactionListener(taxonomy);
    managementService.registerTransactionEventListener(db.databaseName(), listener);
    return null;
}

 Best guess is that I'm not supposed to register a transaction listener this way. But if not this way, then how? There don't seem to be any lifecycle hooks that get called when the database starts, so how can I possibly register an TransactionEventListener?

Or is there a way I can give myself permission to do this?

(The issue I'm exploring here is whether it's possible to validate the state of the database from inside a plugin. We've got a taxonomy that describes the structure of our data, but it's currently completely ignored, and because there are so many ways data can enter our database, checking them all is going to be a lot of work. If we can do this from inside the database instead, that would be much more maintainable and more consistent. This is part of a PoC to see if this could work, but I'm totally open to better solutions if they exist.)

0 REPLIES 0
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online