janusgraph icon indicating copy to clipboard operation
janusgraph copied to clipboard

Cannot use vertex and edge TTL on Hbase

Open denghaiai opened this issue 9 years ago • 13 comments

I saw the document on the JanusGraph website and it said Hbase support vertex and edge TTL setting. I am using JanusGraph 0.2.0 and Hbase 1.1.4. but when the time ran out, the vertex and edge didn't disappear.

denghaiai avatar Oct 27 '17 05:10 denghaiai

Did you try JanusGraph 0.2.0 instead of SNAPSHOT?

pluradj avatar Oct 27 '17 15:10 pluradj

Yes,I have tried it already.

denghaiai avatar Oct 30 '17 07:10 denghaiai

Do you mean JanusGraph 0.2.0 release has the same problem?

jerryjch avatar Oct 30 '17 18:10 jerryjch

Is this related to #448?

jerryjch avatar Oct 30 '17 22:10 jerryjch

#448 said can not set the TTL, 0.2.0 can set it,but when time run out. the TTL doesn't work.

denghaiai avatar Oct 30 '17 23:10 denghaiai

canssandra is ok, but hbase can't.

denghaiai avatar Oct 30 '17 23:10 denghaiai

have the same problem on hbase. Is there any solutions?

adamyxliu avatar Dec 06 '17 02:12 adamyxliu

I finally got a chance to dig into this problem. The problem is with the TIMESTAMP_PROVIDER in janusgraph.

public static final ConfigOption<TimestampProviders> TIMESTAMP_PROVIDER = new ConfigOption<>(GRAPH_NS, "timestamps",
    "The timestamp resolution to use when writing to storage and indices. Sets the time granularity for the " +
    "entire graph cluster. To avoid potential inaccuracies, the configured time resolution should match " +
    "those of the backend systems. Some JanusGraph storage backends declare a preferred timestamp resolution that " +
    "reflects design constraints in the underlying service. When the backend provides " +
    "a preferred default, and when this setting is not explicitly declared in the config file, the backend " +
    "default is used and the general default associated with this setting is ignored.  An explicit " +
    "declaration of this setting overrides both the general and backend-specific defaults.",
    ConfigOption.Type.FIXED, TimestampProviders.class, TimestampProviders.MICRO);

In HBase, the timestamp is always interpreted as millisec. Thus from janusgraph, we need to use millisec.

The reason why the TTL has not been honored is explained here.

I looked at the hfile (hbase data file), which is shown here:

K: (\x00\x00\x00\x00\x00\x00\x84/e:\x02/1514590685901001/Put/vlen=4/seqid=59 V: \x00\x01\x04\x85 T[0]: \x00\x00\x00\x00\x00\x00\x13\x88
K: (\x00\x00\x00\x00\x00\x00\x84/e:$/1514590685901001/Put/vlen=5/seqid=59 V: \x04\x8D\x08\x85\xFF T[0]: \x00\x00\x00\x00\x00\x00\x13\x88

The commit timestamp is 1514590685901001. This is the timestamp that janusgraph sent in as micro sec. But HBase will regard it as millisec. Convert the millisec timestamp to a real date. It is 6/20/49965. This is far in the future. That is why the cell will never expire.
The TTLs were corrected recorded in the cell as T[0]: \x00\x00\x00\x00\x00\x00\x13\x88

jerryjch avatar Jan 02 '18 22:01 jerryjch

Setting the property graph.timestamps will solve the problem. graph.timestamps=MILLI This is a FIXED global property.

jerryjch avatar Jan 02 '18 22:01 jerryjch

From the description of the TIMESTAMP_PROVIDER option, To avoid potential inaccuracies, the configured time resolution should match those of the backend systems. Some JanusGraph storage backends declare a preferred timestamp resolution that reflects design constraints in the underlying service. When the backend provides a preferred default, and when this setting is not explicitly declared in the config file, the backend default is used and the general default associated with this setting is ignored. An explicit declaration of this setting overrides both the general and backend-specific defaults.

HBaseStoreManager defines a preferred TIMESTAMP_PROVIDER: public static final TimestampProviders PREFERRED_TIMESTAMPS = TimestampProviders.MILLI; Apparently, the 'preferred default' logic is broken in general janusgraph configuration.

jerryjch avatar Jan 02 '18 22:01 jerryjch

We need to:

  1. Fix the 'preferred default' logic in general janusgraph configuration.
  2. We should require MILLI always for HBase backend.

jerryjch avatar Jan 02 '18 22:01 jerryjch

To conclude this Issue, we will fix:

  • [x] #862
  • [x] #887

These two should be able to cover this Issue.

jerryjch avatar Jan 15 '18 19:01 jerryjch

I am closing this issue while marking #887 for 0.21 release.

jerryjch avatar May 03 '18 04:05 jerryjch