Dgraph gRPC cli - Transaction has been aborted

Report a Dgraph Client Bug

Keep getting the error Transaction has been aborted with Javascript gRpc client. Dgraph reboot needed.

What Dgraph client (and version) are you using?

(put “x” in the box to select)

  • Dgo
  • PyDgraph
  • Dgraph4J
  • Dgraph-js
  • Dgraph-js-http
  • Dgraph.NET

Version: latest

What version of Dgraph are you using?


Have you tried reproducing the issue with the latest release?


What is the hardware spec (RAM, OS)?

MacBook Pro 16" / OSX / 16 Gb ram

Steps to reproduce the issue (command/config used to run Dgraph).

I have a simple schema like this:

user.username: string @index(exact) .
user.email: string .
user.follow: [uid] @count @reverse .
user.id: string @index(exact) .
type User {

I’m trying to load a bunch of random users with the following script:

import dgraph from 'dgraph-js';
import faker from 'faker';
import _ from 'lodash';

import schema from './schema.mjs';

const clientStub = new dgraph.DgraphClientStub('localhost:9080');
const dgraphClient = new dgraph.DgraphClient(clientStub);

const NB_USERS = 3000;

class Fixtures {
    constructor(client) {
        this.client = client;

    async load() {
        // await this.cleanGraph();
        // await this.loadSchema();
        const users = await this.loadUsers();

    async cleanGraph() {
        const op = new dgraph.Operation();
        await this.client.alter(op);

    async loadSchema() {
        const op = new dgraph.Operation();
        await this.client.alter(op);

    async loadUsers() {
        const users = [];
        const userIds = _.range(0, NB_USERS - 1);
        for (let i = 0; i < NB_USERS; i += 1) {
                uid: `_:user${i}`,
                'dgraph.type': 'User',
                'user.id': faker.datatype.uuid(),
                'user.username': faker.internet.userName(),
                'user.name': faker.name.findName(),
                'user.email': faker.internet.email(),
                'user.follow': _.sampleSize(userIds, _.random(1, NB_USERS / 10)).map((userId) => ({ uid: `_:user${userId}` })),
        await this.loadObjects(users);

    async loadObjects(objects) {
        const txn = this.client.newTxn();
        const mutations = [];
        for (let i = 0; i < objects.length; i += 1) {
            const mu = new dgraph.Mutation();
        const req = new dgraph.Request();

        await txn.doRequest(req);

// dgraphClient.setDebugMode(true);

const fixtures = new Fixtures(dgraphClient);

I have a bunch of problems.

  1. Load a lot of data.
    First, when I load about 1000 users, it’s quite fast to load. But with, 5000 it takes a really long time and fails most of the time (No matter if I run Dgraph with or without Docker).

  2. Running transaction again
    Also, after the initial load, I can no longer run my script and I keep getting the error Error: Transaction has been aborted. Please retry. I have to completely reboot Dgraph in order to make it work again.

  3. Query ordered by count
    Lastly, when it works, I’m trying to run a query to get users ordered by the number of followers with a query like this:

  q(func: Type("User"), orderdesc: followers) {
    followers: count(~user.follow) 
    following: count(user.follow)

But Dgraph doesn’t accept it and fails with the error : Cannot sort by unknown attribute followers.

Thank you for reading me guys. Dgraph seems really good.

This should be like this

  U as var(func: Type("User"), orderdesc: followers) {
    FS as : count(~user.follow) 

  q(func: uid(U), orderdesc: val(FS)) {
    followers: val(FS) 
    following: count(user.follow)
1 Like