StartTs cannot be zero while committing a transaction (v20.07.0)

I tried to do the mutation operation. Three attempts:

operation dgraph version client result
mutation v20.07.0 dgraph4j v20.03.0 StartTs cannot be zero while committing a transaction
mutation v20.03.0 dgraph4j v20.03.0 success
mutation v20.07.0 dgraph ratel success

can you paste the code that you are trying with dgraph4j?

I used the official demo
I edited the build.gradle file and modified the dgraph version.
this is my docker-compose.yml file

version: "3.2"
services:
  zero:
    image: dgraph/dgraph:v20.07.0
    volumes:
      - type: volume
        source: dgraph
        target: /dgraph
        volume:
          nocopy: true
    # ports:
    #   - 5180:5080
    #   - 6180:6080
    restart: on-failure
    command: dgraph zero --my=zero:5080 --ludicrous_mode
  server:
    image: dgraph/dgraph:v20.07.0
    volumes:
      - type: volume
        source: dgraph
        target: /dgraph
        volume:
          nocopy: true
    ports:
      - 8180:8080
      - 9180:9080
    restart: on-failure
    command: dgraph alpha --whitelist 172.17.0.1:172.24.255.255 --ludicrous_mode --my=server:7080 --lru_mb=20480 --zero=zero:5080 --postings out/0/p
  ratel:
    image: dgraph/dgraph:v20.07.0
    volumes:
      - type: volume
        source: dgraph
        target: /dgraph
        volume:
          nocopy: true
    ports:
      - 8100:8000
    command: dgraph-ratel

volumes:
  dgraph:

That would work without ludicrous_mode. Let me find out if clients are supposed to work with ludicrous_mode.

You need to add setCommitNow(true) while building the mutation object and then just do txn.mutate(mutation) and not txn.commit().

Mutation mutation =
          Mutation.newBuilder().setSetJson(ByteString.copyFromUtf8(json.toString())).setCommitNow(true).build();
      txn.mutate(mutation);
// remove below line
//      txn.commit();

That will make it work for now.

This seems like a bug in Dgraph’s ludicrous_mode when commitNow is not given, it fails.
Marking it as a bug.

Thanks for reporting.

Ludicrous mode does not have transactions, so examples with transactions won’t work.