Transactions are not working

27 views
Skip to first unread message

Mauricio Orellana

unread,
Apr 28, 2017, 12:02:09 AM4/28/17
to Sparksee
I want to load a lot of data using transactions. I do a commit every 1000 nodes inserted, I watch database file size while the process is loading data, but file size does not increase. Only when the database is closed the database size increase it size.

I have defined class members:

SparkseeConfig conf = new SparkseeConfig();
Sparksee sparksee;
Database db;
Session sparksee_session;
Graph
sparksee_graph;


I have a method to create database

    public void createDB(dbname) {
       sparksee = new Sparksee(conf);
       dbfilename = dbname + ".dex";
       db = sparksee.create(dbfilename, dbname);
       this.defineSchema();  // define nodes and attributes
    }

I have the following two methods for manage transactions

    public boolean openTransaction() {
       
try {
            sparksee_session
= db.newSession();
            sparksee_session
.begin();
            sparksee_graph
= sparksee_session.getGraph();
           
return true;
       
} catch (Exception e) {
           
System.out.println(e.getMessage());
           
return false;
       
}
   
}

    public boolean closeTransaction() {
        try {
            sparksee_session.commit();
            sparksee_session.close();
            sparksee_session.delete();
            return true;
        } catch (Exception e) {
            System.out.println(e.getMessage());
            return false;
        }
    }

Finally I inserted data

long inserted = 0;
for (Data data : mydata) { // 1M of nodes
    long node = sparksee_graph.newNode(person);
    sparksee_graph.setAttribute(node, ...);

    // others basic operations here

    inserted++;
    if (inserted >= 1000){
        
this.closeTransaction();
        this.openTransaction();
        insertions = 0;
    }
}

What is the problem of this?

PD: I got the desired behavior setting CacheMaxSize in Database class, but I do not sure if this is really necessary.

c3po.ac

unread,
Apr 28, 2017, 5:32:31 AM4/28/17
to Sparksee

Hi,


You'll have to enable first the recovery system, like this:


SparkseeConfig conf = new SparkseeConfig();

conf
.setRecoveryEnabled(true);


Check more information about the recovery here.

Commits should then make grow your main database file and/or the recovery log.


Lowering the CacheMaxSize makes the database file grow because not all the information fits in memory anymore. But since your data is not safe without recovery,  we recommend enabling it although it may have a small performance penalty and not lowering CacheMaxSize too much.


Best regards,

El divendres, 28 abril de 2017 6:02:09 UTC+2, Mauricio Orellana va escriure:

Mauricio Orellana

unread,
Apr 28, 2017, 4:55:09 PM4/28/17
to Sparksee
Thank you!
Reply all
Reply to author
Forward
0 new messages