function runSetup () {
  internal.debugClearFailAt();
  var i;
  
  db._drop("UnitTestsRecovery1");
  db._drop("UnitTestsRecovery2");
  db._create("UnitTestsRecovery1");
  db.UnitTestsRecovery1.properties({ journalSize: 8 * 1024 * 1024, doCompact: false });

  for (i = 0; i < 1000; ++i) {
    db.UnitTestsRecovery1.save({ a: i });
  }

  db.UnitTestsRecovery1.rename("UnitTestsRecovery2");
  
  db._create("UnitTestsRecovery1");
 
  for (i = 0; i < 99; ++i) {
    db.UnitTestsRecovery1.save({ a: i });
  }

  db.UnitTestsRecovery1.save({ _key: "foo" }, true);

  internal.debugSegfault("crashing server");
}
Example #2
0
function runSetup () {
  'use strict';
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery1");
  var c = db._create("UnitTestsRecovery1"), i;
  c.ensureHashIndex("value", { sparse: true });

  for (i = 0; i < 1000; ++i) {
    c.save({ value: i });
  }

  db._drop("UnitTestsRecovery2");
  c = db._create("UnitTestsRecovery2");
  c.ensureUniqueConstraint("a.value", { sparse: true });

  for (i = 0; i < 1000; ++i) {
    c.save({ a: { value: i } });
  }
  
  db._drop("UnitTestsRecovery3");
  c = db._create("UnitTestsRecovery3");
  c.ensureHashIndex("a", "b", { sparse: true });

  for (i = 0; i < 500; ++i) {
    c.save({ a: (i % 2) + 1, b: 1 });
    c.save({ a: (i % 2) + 1, b: 2 });
  }

  db._drop("test");
  c = db._create("test");
  c.save({ _key: "crashme" }, true);

  internal.debugSegfault("crashing server");
}
Example #3
0
function runSetup () {
  'use strict';
  internal.debugClearFailAt();
  var c;
  
  db._drop("UnitTestsRecovery1");
  db._drop("UnitTestsRecovery2");
  c = db._create("UnitTestsRecovery1");
  c.properties({ waitForSync: true, journalSize: 8 * 1024 * 1024, doCompact: false });
  c.rename("UnitTestsRecovery2");
  
  db._drop("UnitTestsRecovery3");
  db._drop("UnitTestsRecovery4");
  c = db._create("UnitTestsRecovery3");
  c.properties({ waitForSync: false, journalSize: 16 * 1024 * 1024, doCompact: true });
  c.rename("UnitTestsRecovery4");
  
  db._drop("UnitTestsRecovery5");
  db._drop("UnitTestsRecovery6");
  c = db._create("UnitTestsRecovery5");
  c.rename("UnitTestsRecovery6");
  c.rename("UnitTestsRecovery5");
  
  db._drop("UnitTestsRecovery7");
  db._drop("UnitTestsRecovery8");
  c = db._create("UnitTestsRecovery7");
  c.rename("UnitTestsRecovery8");
  db._drop("UnitTestsRecovery8");
  c = db._create("UnitTestsRecovery8");

  c.save({ _key: "foo" }, true);

  internal.debugSegfault("crashing server");
}
Example #4
0
function runSetup () {
  'use strict';
  internal.debugClearFailAt();

  var c; 
  db._drop("UnitTestsRecovery1");
  c = db._create("UnitTestsRecovery1", {
    waitForSync: true,
    journalSize: 8 * 1024 * 1024,
    doCompact: false
  });

  c.save({ value1: 1, value2: [ "the",
                                "quick",
                                "brown",
                                "foxx",
                                "jumped",
                                "over",
                                "the",
                                "lazy",
                                "dog",
                                "xxxxxxxxxxx" ] });
  c.ensureHashIndex("value1");
  c.ensureSkiplist("value2");

  db._drop("UnitTestsRecovery2");
  c = db._create("UnitTestsRecovery2", {
    waitForSync: false,
    journalSize: 16 * 1024 * 1024,
    doCompact: true,
    isVolatile: true
  });

  c.save({ value1: { "some" : "rubbish" } });
  c.ensureSkiplist("value1");

  db._drop("UnitTestsRecovery3");
  c = db._createEdgeCollection("UnitTestsRecovery3", {
    waitForSync: false,
    journalSize: 32 * 1024 * 1024,
    doCompact: true
  });

  c.save("UnitTestsRecovery1/foo", "UnitTestsRecovery2/bar", { value1: { "some" : "rubbish" } });
  c.ensureUniqueSkiplist("value1");

  db._drop("_UnitTestsRecovery4");
  c = db._create("_UnitTestsRecovery4", { isSystem: true });
  c.save({ value42: 42 });
  c.ensureUniqueConstraint("value42");

  c.save({ _key: "crashme" }, true);

  internal.debugSegfault("crashing server");
}
Example #5
0
function runSetup () {
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery"), i;
  internal.wal.flush(true, true);
  internal.wal.properties({ throttleWait: 1000, throttleWhenPending: 1000 });

  for (i = 0; i < 10000; ++i) {
    c.save({ _key: "test" + i, value1: "test" + i, value2: i }); 
  }
  
  internal.debugSetFailAt("CollectorThreadProcessQueuedOperations");
  internal.wal.flush(true, false);

  // now let the write throttling become active
  internal.wait(7);
  try {
    c.save({ _key: "foo" });
  }
  catch (err) {
  }

  internal.debugSegfault("crashing server");
}
Example #6
0
function runSetup () {
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  db._create("UnitTestsRecovery");

  try {
    db._executeTransaction({
      collections: {
        write: "UnitTestsRecovery"
      },
      action: function () {
        var db = require("org/arangodb").db;

        var i, c = db._collection("UnitTestsRecovery");
        for (i = 0; i < 100; ++i) {
          c.save({ _key: "test" + i, value1: "test" + i, value2: i }, true); // wait for sync
        }
  
        internal.debugSetFailAt("TransactionWriteAbortMarker");

        throw "rollback!";
      }
    });
  }
  catch (err) {
    // suppress error we're intentionally creating
  }

  internal.debugSegfault("crashing server");
}
Example #7
0
function runSetup () {
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  db._create("UnitTestsRecovery");

  db._executeTransaction({
    collections: {
      write: "UnitTestsRecovery"
    },
    action: function () {
      var db = require("org/arangodb").db;

      var i, c = db._collection("UnitTestsRecovery");
      for (i = 0; i < 10000; ++i) {
        c.save({ _key: "test" + i, value1: "test" + i, value2: i }); 
        c.update("test" + i, { value3: "additional value", value4: i }); 

        if (i % 10 === 0) {
          c.remove("test" + i, true);
        }
        else if (i % 5 === 0) {
          c.update("test" + i, { value6: "something else" }); 
        }
      }
    }
  });

  internal.wal.flush(true, true);

  internal.debugSegfault("crashing server");
}
Example #8
0
function runSetup () {
  "use strict";
  internal.debugClearFailAt();
  var i, j, c;
  for (i = 0; i < 5; ++i) {
    db._drop("UnitTestsRecovery" + i);
    c = db._create("UnitTestsRecovery" + i);
    c.save({ _key: "foo", value1: "foo", value2: "bar" });

    c.ensureHashIndex("value1");
    c.ensureSkiplist("value2");
    c.ensureCapConstraint(1000);
  }
  
  // drop all indexes but primary
  for (i = 0; i < 4; ++i) {
    c = db._collection("UnitTestsRecovery" + i);
    var idx = c.getIndexes();
    for (j = 0; j < idx.length; ++j) {
      c.dropIndex(idx[j].id);
    }
  }
    
  c.save({ _key: "crashme" }, true);

  internal.debugSegfault("crashing server");
}
function runSetup () {
  "use strict";
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  db._create("UnitTestsRecovery");

  db._executeTransaction({
    collections: {
      write: "UnitTestsRecovery"
    },
    action: function () {
      var db = require("org/arangodb").db;

      var i, c = db._collection("UnitTestsRecovery");
      for (i = 0; i < 100000; ++i) {
        c.save({ _key: "test" + i, value1: "test" + i, value2: i }, true); // wait for sync
      }
      for (i = 0; i < 100000; i += 2) {
        c.remove("test" + i, true);
      }
    }
  });

  internal.debugSegfault("crashing server");
}
Example #10
0
function runSetup () {
  "use strict";
  internal.debugClearFailAt();

  db._drop("test");
  db._create("test");
  
  var i;
  for (i = 0; i < 5; ++i) {
    db._useDatabase("_system");

    try {
      db._dropDatabase("UnitTestsRecovery" + i);
    } 
    catch (err) {
      // ignore this error
    }

    db._createDatabase("UnitTestsRecovery" + i);
    db._useDatabase("UnitTestsRecovery" + i);
    db._create("test");
    db.test.save({ value: i });
  }

  db._useDatabase("_system");
    
  db.test.save({ _key: "crashme" }, true);

  internal.debugSegfault("crashing server");
}
function runSetup () {
  'use strict';
  var doc;
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery"), i;
  
  for (i = 0; i < 99; ++i) {
    c.save({ _key: "test" + i, value: "test" + i });
  }

  // insert 100th marker
  c.save({ _key: "test99", value: "test" + i }, true); // sync 

  internal.debugSetFailAt("WalSlotCrc");

  // now corrupt the collection
  c.save({ _key: "test100", value: "test100" });
  
  internal.debugClearFailAt();
  
  for (i = 101; i < 199; ++i) {
    c.save({ _key: "test" + i, value: "test" + i });
  }
  c.save({ _key: "test199", value: "test199" }, true); // sync 

  internal.debugSegfault("crashing server");
}
function runSetup () {
  'use strict';
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery"); 
  internal.wal.flush(true, true);
  internal.debugSetFailAt("CreateDatafile1");
  internal.debugSetFailAt("LogfileManagerGetWriteableLogfile");

  c.insert({ value: 1 });
  try {
    internal.wal.flush();
    fail();
  }
  catch (err) {
  }

  internal.wait(3);
  try {
    c.save({ _key: "crashme" }, true); // wait for sync
    fail();
  }
  catch (err) {
  }

  internal.debugSegfault("crashing server");
}
function runSetup () {
  'use strict';
  var i;
  internal.debugClearFailAt();

  internal.wal.properties({ historicLogfiles: 0 });
  
  db._drop("test");
  db._create("test");

  db._createDatabase("UnitTestsRecovery");
  internal.wal.flush(true, true, true);
  internal.wait(3, true);

  db._useDatabase("UnitTestsRecovery");

  db._create("test");
  for (i = 0; i < 100; ++i) {
    db.test.save({ _key: "test" + i, value: i });
  }
    
  db._useDatabase("_system");
  db._dropDatabase("UnitTestsRecovery");

  internal.wait(5, true);

  db.test.save({ _key: "crashme" }, true);

  internal.debugSegfault("crashing server");
}
Example #14
0
function runSetup () {
  "use strict";
  internal.debugClearFailAt();
  
  var i;
  for (i = 0; i < 5; ++i) {
    db._drop("UnitTestsRecovery" + i);
    db._create("UnitTestsRecovery" + i);
  }

  for (i = 0; i < 4; ++i) {
    db._drop("UnitTestsRecovery" + i);
  }

  db.UnitTestsRecovery4.save({ _key: "crashme" }, true); // wait for sync

  internal.debugSegfault("crashing server");
}
Example #15
0
function runSetup () {
  internal.debugClearFailAt();
  var c;
  
  db._drop("UnitTestsRecovery");
  c = db._create("UnitTestsRecovery");

  c.save({ _key: "foo", value1: 1, value2: "test" }, true);

  internal.debugSegfault("crashing server");
}
Example #16
0
function runSetup () {
  'use strict';
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery1");
  var c = db._create("UnitTestsRecovery1"), i, j;
  c.ensureGeoIndex("loc");
  c.ensureGeoIndex("lat", "lon");

  for (i = -40; i < 40; ++i) {
    for (j = -40; j < 40; ++j) {
      c.save({ loc: [ i, j ], lat: i, lon: j });
    }
  }

  db._drop("UnitTestsRecovery2");
  c = db._create("UnitTestsRecovery2");
  c.ensureGeoConstraint("a.loc", true, true);

  for (i = -40; i < 40; ++i) {
    for (j = -40; j < 40; ++j) {
      c.save({ a: { loc: [ i, j ] } });
    }
  }
  
  db._drop("UnitTestsRecovery3");
  c = db._create("UnitTestsRecovery3");
  c.ensureGeoConstraint("a.lat", "a.lon", false);

  for (i = -40; i < 40; ++i) {
    for (j = -40; j < 40; ++j) {
      c.save({ a: { lat: i, lon: j } });
    }
  }

  db._drop("test");
  c = db._create("test");
  c.save({ _key: "crashme" }, true);

  internal.debugSegfault("crashing server");
}
function runSetup () {
  "use strict";
  internal.debugClearFailAt();

  var i, paths = [ ];
  for (i = 0; i < 3; ++i) {
    db._useDatabase("_system");
    try {
      db._dropDatabase("UnitTestsRecovery" + i);
    }
    catch (err) {
    }

    db._createDatabase("UnitTestsRecovery" + i);
    db._useDatabase("UnitTestsRecovery" + i);
    paths[i] = db._path();
    
    db._useDatabase("_system");
    db._dropDatabase("UnitTestsRecovery" + i);
  }

  db._drop("test");
  var c = db._create("test");
  c.save({ _key: "crashme" }, true);

  internal.wait(3, true);
  for (i = 0; i < 3; ++i) {
    // re-create database directory
    try {
      fs.makeDirectory(paths[i]);
    }
    catch (err2) {
    }

    fs.write(fs.join(paths[i], "parameter.json"), "");
    fs.write(fs.join(paths[i], "parameter.json.tmp"), "");

    // create some collection directory
    fs.makeDirectory(fs.join(paths[i], "collection-123"));
    if (i < 2) {
      // create a leftover parameter.json.tmp file
      fs.write(fs.join(paths[i], "collection-123", "parameter.json.tmp"), "");
    }
    else {
      // create an empty parameter.json file
      fs.write(fs.join(paths[i], "collection-123", "parameter.json"), "");
      // create some other file
      fs.write(fs.join(paths[i], "collection-123", "foobar"), "foobar");
    }
  }

  internal.debugSegfault("crashing server");
}
Example #18
0
function runSetup () {
  internal.debugClearFailAt();
  
  var c;
  db._drop("footest");
  c = db._create("footest", { id: 99999999 });
  c.save({ foo: "bar" });
  c.save({ foo: "bart" });
  db._drop("footest");

  internal.wait(2);

  c = db._create("footest", { id: 99999999 });
  c.save({ foo: "baz" });

  db._drop("test");
  c = db._create("test");
  c.save({ _key: "crashme" }, true);

  internal.debugSegfault("crashing server");
}
Example #19
0
function runSetup () {
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery"), i;

  for (i = 0; i < 200000; ++i) {
    c.save({ _key: "test" + i, value1: "test" + i, value2: i });
  }
  c.save({ _key: "crashme" }, true);

  internal.debugSegfault("crashing server");
}
Example #20
0
function runSetup () {
  "use strict";
  internal.debugClearFailAt();

  var i, j, c; 
  for (i = 0; i < 5; ++i) {
    db._drop("UnitTestsRecovery" + i);
    c = db._create("UnitTestsRecovery" + i);

    c.ensureCapConstraint((i + 1) * 10);

    for (j = 0; j < 100; ++j) {
      c.save({ _key: "test" + j, value1: i, value2: j });
    }
  }

  db._drop("test");
  c = db._create("test");
  c.save({ _key: "crashme" }, true);

  internal.debugSegfault("crashing server");
}
Example #21
0
function runSetup () {
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery"), i;

  for (i = 0; i < 1000; ++i) {
    c.save({ _key: "test" + i, value1: "test" + i });
  }

  // make sure the next operations go into a separate log
  internal.wal.flush(true, true);

  db._drop("UnitTestsRecovery");
  c = db._create("UnitTestsRecovery");
  for (i = 0; i < 100; ++i) {
    c.save({ _key: "test" + i, value1: i });
  }

  c.save({ _key: "foo" }, true);

  internal.debugSegfault("crashing server");
}
Example #22
0
function runSetup () {
  "use strict";
  internal.debugClearFailAt();
  
  // disable collector
  internal.debugSetFailAt("CollectorThreadProcessQueuedOperations");

  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery"), i;

  for (i = 0; i < 1000; ++i) {
    c.save({ _key: "test" + i, value1: "test" + i });
  }

  // make sure the next operations go into a separate log
  internal.wal.flush(true, false);

  db._drop("UnitTestsRecovery");
  c = db._create("UnitTestsRecovery2");

  c.save({ _key: "foo" }, true);

  internal.debugSegfault("crashing server");
}
Example #23
0
function runSetup () {
  "use strict";
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery"), i;

  c.save({ _key: "value", value: 42 });
  for (i = 0; i < 200000; ++i) {
    c.update("value", { value: i });
  }
  c.save({ _key: "crashme" }, true);

  internal.debugSegfault("crashing server");
}
Example #24
0
function runSetup () {
  internal.debugClearFailAt();
  
  var c, v, e, i;
  db._drop("UnitTestsVertices");
  db._drop("UnitTestsEdges");

  v = db._create("UnitTestsVertices");
  e = db._createEdgeCollection("UnitTestsEdges");

  for (i = 0; i < 1000; ++i) {
    v.save({ _key: "node" + i, name: "some-name" + i });
  }

  for (i = 0; i < 1000; ++i) {
    e.save("UnitTestsVertices/node" + i, "UnitTestsVertices/node" + (i % 10), { _key: "edge" + i, what: "some-value" + i });
  }
   
  db._drop("test");
  c = db._create("test"); 
  c.save({ _key: "crashme" }, true); // wait for sync

  internal.debugSegfault("crashing server");
}
Example #25
0
function runSetup () {
  "use strict";
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery"), i;
  for (i = 0; i < 10000; ++i) {
    c.save({ _key: "test" + i, value1: "test" + i, value2: i }); 
  }

  internal.debugSetFailAt("CollectorThreadProcessQueuedOperations");
  internal.wal.flush(true, false);
  internal.wait(5);

  internal.debugSegfault("crashing server");
}
function runSetup () {
  'use strict';
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery");
  c.ensureHashIndex("foo", "bar");

  c.save({ _key: "test", "foo": 1, "bar": 2 }, true);

  internal.wal.flush(true, true);
  internal.wal.flush(true, false);

  internal.wait(2);
  internal.debugSegfault("crashing server");
}
Example #27
0
function runSetup () {
  "use strict";
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery"), i;

  for (i = 0; i < 1000; ++i) {
    var doc = { _key: "foo" + i };
    doc["test" + i] = "foobar" + i;
    c.save(doc);
  }
    
  c.save({ _key: "crashme" }, true); // wait for sync

  internal.debugSegfault("crashing server");
}
Example #28
0
function runSetup () {
  internal.debugClearFailAt();
  
  var i, num = 9999999999;
  for (i = 0; i < 4; ++i) {
    var filename = fs.join(db._path(), "../../journals/logfile-" + num + ".db");
    num++;

    // save an empty file 
    fs.write(filename, "");
  }
  
  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery"); 
  c.save({ _key: "crashme" }, true); // wait for sync

  internal.debugSegfault("crashing server");
}
Example #29
0
function runSetup () {
  "use strict";
  internal.debugClearFailAt();

  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery");
  var i, num = 9999999999;
  for (i = 0; i < 4; ++i) {
    var filename = fs.join(db._path(), "collection-" + c._id + "/datafile-" + num + ".db");
    num++;

    // save an empty file 
    fs.write(filename, "");
  }

  c.save({ test: "testValue" }, true); // wait for sync
  
  internal.debugSegfault("crashing server");
}
function runSetup () {
  "use strict";
  internal.debugClearFailAt();
  
  db._drop("UnitTestsRecovery");
  var c = db._create("UnitTestsRecovery"), i;

  c.ensureHashIndex("value1");
  c.ensureSkiplist("value2");

  for (i = 0; i < 100; ++i) {
    c.save({ value1: i, value2: i });
  }

  c.drop();
  internal.wait(3);

  internal.debugSegfault("crashing server");
}