You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "lzshlzsh (via GitHub)" <gi...@apache.org> on 2023/05/20 15:13:52 UTC
[GitHub] [flink] lzshlzsh opened a new pull request, #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
lzshlzsh opened a new pull request, #22612:
URL: https://github.com/apache/flink/pull/22612
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink upsert data to hbase.
#32139
## Brief change log
- Add a class HBaseTimestampGenerator which generates strongly increasing timestamp in nanoseconds to set to hbase mutation.
- HBaseSerde createPutMutation and createDeleteMutation use muation with timestamp.
- delete.addColumns instead of delete.addColumn, the first hbase client api use [DeleteColumn key type](https://github.com/apache/hbase/blob/c05ee564d3026688bcfdc456071059c7c8409694/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Delete.java#L322) and the second use [Delete key type](https://github.com/apache/hbase/blob/c05ee564d3026688bcfdc456071059c7c8409694/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Delete.java#L380).
## Verifying this change
- Added test that validates that HBaseTimestampGenerator generates strongly increasing timestamp.
- Online test described in #32139
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] lzshlzsh commented on pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "lzshlzsh (via GitHub)" <gi...@apache.org>.
lzshlzsh commented on PR #22612:
URL: https://github.com/apache/flink/pull/22612#issuecomment-1561476801
@flinkbot run azure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] MartijnVisser commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "MartijnVisser (via GitHub)" <gi...@apache.org>.
MartijnVisser commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1200536398
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
Review Comment:
Please have a look at https://flink.apache.org/how-to-contribute/code-style-and-quality-common/#7-testing - Having a test run 100 million times isn't an effective test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] 1996fanrui commented on pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "1996fanrui (via GitHub)" <gi...@apache.org>.
1996fanrui commented on PR #22612:
URL: https://github.com/apache/flink/pull/22612#issuecomment-1578048447
Hi @MartijnVisser , thanks for the reviewing and merging.
A friendly reminder: Please note the squish commit before merging and the commit message should start with [FLINK-JIRA_ID], thanks~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] lzshlzsh commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "lzshlzsh (via GitHub)" <gi...@apache.org>.
lzshlzsh commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1202716866
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
Review Comment:
> Please have a look at https://flink.apache.org/how-to-contribute/code-style-and-quality-common/#7-testing - Having a test run 100 million times isn't an effective test
@MartijnVisser
Thank you for your review and valuable feedback. I think I may need to use Junit5 to write test cases, and change 100 million times tests to one times。Can you give more suggestions on how to write this test?
Actually, I have another question. How to write test cases for the probability of errors occurring in this data loss situation, as we cannot assert a definite state ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] lzshlzsh commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "lzshlzsh (via GitHub)" <gi...@apache.org>.
lzshlzsh commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1204404313
##########
flink-connectors/flink-connector-hbase-base/src/main/java/org/apache/flink/connector/hbase/util/HBaseTimestampGenerator.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+/** Generate timestamp for HBase mutation. */
+public abstract class HBaseTimestampGenerator {
Review Comment:
> Is there a chance we will have another implementation for this class in the future? Even if yes, I think we can introduce the extra abstraction layer when it will be necessary. For now, a simple class, e.g. `StronglyIncreasingTsGenerator` with 1 public method that returns the ts would be enough, resulting a simpler and cleaner solution.
Thank you for your feedback. I will make some modifications according to your suggesion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] MartijnVisser commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "MartijnVisser (via GitHub)" <gi...@apache.org>.
MartijnVisser commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1200536398
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
Review Comment:
Please have a look at https://flink.apache.org/how-to-contribute/code-style-and-quality-common/#avoid-timeouts-in-junit-tests - Having a test run 100 million times isn't an effective test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] MartijnVisser merged pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "MartijnVisser (via GitHub)" <gi...@apache.org>.
MartijnVisser merged PR #22612:
URL: https://github.com/apache/flink/pull/22612
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] lzshlzsh commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "lzshlzsh (via GitHub)" <gi...@apache.org>.
lzshlzsh commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1199953412
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ private static final Logger LOG = LoggerFactory.getLogger(HBaseTimestampGeneratorTest.class);
+
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
+ long now = timestampGenerator.get();
+ if (lastTimestamp > 0) {
+ assertTrue(lastTimestamp < now);
+ }
+ lastTimestamp = now;
+ }
+ final long realNow = timestampGenerator.getCurrentSystemTimeNano();
+ final long diff = lastTimestamp - realNow;
Review Comment:
good idea
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] lzshlzsh commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "lzshlzsh (via GitHub)" <gi...@apache.org>.
lzshlzsh commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1199952919
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ private static final Logger LOG = LoggerFactory.getLogger(HBaseTimestampGeneratorTest.class);
+
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
+ long now = timestampGenerator.get();
+ if (lastTimestamp > 0) {
+ assertTrue(lastTimestamp < now);
+ }
+ lastTimestamp = now;
+ }
+ final long realNow = timestampGenerator.getCurrentSystemTimeNano();
+ final long diff = lastTimestamp - realNow;
+ assertTrue("Should no timestamp diff in 100 billion tests", diff <= 0);
Review Comment:
Thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] kylemeow commented on pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "kylemeow (via GitHub)" <gi...@apache.org>.
kylemeow commented on PR #22612:
URL: https://github.com/apache/flink/pull/22612#issuecomment-1556521018
Also, it is recommended that you add test cases to verify this HBase data loss issue is completely fixed with this solution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] ferenc-csaky commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "ferenc-csaky (via GitHub)" <gi...@apache.org>.
ferenc-csaky commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1203959764
##########
flink-connectors/flink-connector-hbase-base/src/main/java/org/apache/flink/connector/hbase/util/HBaseTimestampGenerator.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+/** Generate timestamp for HBase mutation. */
+public abstract class HBaseTimestampGenerator {
Review Comment:
Is there a chance we will have another implementation for this class in the future? Even if yes, I think we can introduce the extra abstraction layer when it will be necessary. For now, a simple class, e.g. `StronglyIncreasingTsGenerator` with 1 public method that returns the ts would be enough, resulting a simpler and cleaner solution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] lzshlzsh commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "lzshlzsh (via GitHub)" <gi...@apache.org>.
lzshlzsh commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1204404313
##########
flink-connectors/flink-connector-hbase-base/src/main/java/org/apache/flink/connector/hbase/util/HBaseTimestampGenerator.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+/** Generate timestamp for HBase mutation. */
+public abstract class HBaseTimestampGenerator {
Review Comment:
> Is there a chance we will have another implementation for this class in the future? Even if yes, I think we can introduce the extra abstraction layer when it will be necessary. For now, a simple class, e.g. `StronglyIncreasingTsGenerator` with 1 public method that returns the ts would be enough, resulting a simpler and cleaner solution.
Thank you for your feedback. I will make some modifications according to your suggestion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] lzshlzsh commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "lzshlzsh (via GitHub)" <gi...@apache.org>.
lzshlzsh commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1199951039
##########
flink-connectors/flink-connector-hbase-base/src/main/java/org/apache/flink/connector/hbase/util/HBaseTimestampGenerator.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+/** Generate timestamp for hbase mutation. */
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] lzshlzsh commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "lzshlzsh (via GitHub)" <gi...@apache.org>.
lzshlzsh commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1202716866
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
Review Comment:
> Please have a look at https://flink.apache.org/how-to-contribute/code-style-and-quality-common/#7-testing - Having a test run 100 million times isn't an effective test
Thank you for your review and valuable feedback. I think I may need to use Junit5 to write test cases, and change 100 million times tests to one times。Can you give more suggestions on how to write this test?
Actually, I have another question. How to write test cases for the probability of errors occurring in this data loss situation, as we cannot assert a definite state ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #22612:
URL: https://github.com/apache/flink/pull/22612#issuecomment-1555933957
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "a2341810a244b97a3af32951e17efbc49f570cdd",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "a2341810a244b97a3af32951e17efbc49f570cdd",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* a2341810a244b97a3af32951e17efbc49f570cdd UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] lzshlzsh commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "lzshlzsh (via GitHub)" <gi...@apache.org>.
lzshlzsh commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1199953156
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ private static final Logger LOG = LoggerFactory.getLogger(HBaseTimestampGeneratorTest.class);
+
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
+ long now = timestampGenerator.get();
+ if (lastTimestamp > 0) {
+ assertTrue(lastTimestamp < now);
+ }
+ lastTimestamp = now;
+ }
+ final long realNow = timestampGenerator.getCurrentSystemTimeNano();
+ final long diff = lastTimestamp - realNow;
+ assertTrue("Should no timestamp diff in 100 billion tests", diff <= 0);
+ LOG.info(
+ "timestamp diff of 100 billion tests in nanosecond: {} (use {}, real {})",
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] kylemeow commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "kylemeow (via GitHub)" <gi...@apache.org>.
kylemeow commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1199948064
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ private static final Logger LOG = LoggerFactory.getLogger(HBaseTimestampGeneratorTest.class);
+
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
+ long now = timestampGenerator.get();
+ if (lastTimestamp > 0) {
+ assertTrue(lastTimestamp < now);
Review Comment:
Better to use 'now > lastTimestamp' as assertion condition to explicitly show that timestamp is increasing
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ private static final Logger LOG = LoggerFactory.getLogger(HBaseTimestampGeneratorTest.class);
+
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
+ long now = timestampGenerator.get();
+ if (lastTimestamp > 0) {
+ assertTrue(lastTimestamp < now);
+ }
+ lastTimestamp = now;
+ }
+ final long realNow = timestampGenerator.getCurrentSystemTimeNano();
+ final long diff = lastTimestamp - realNow;
Review Comment:
Better to use 'realNow - lastTimestamp' to explicitly show that the timestamp is increasing
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ private static final Logger LOG = LoggerFactory.getLogger(HBaseTimestampGeneratorTest.class);
+
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
+ long now = timestampGenerator.get();
+ if (lastTimestamp > 0) {
+ assertTrue(lastTimestamp < now);
+ }
+ lastTimestamp = now;
+ }
+ final long realNow = timestampGenerator.getCurrentSystemTimeNano();
+ final long diff = lastTimestamp - realNow;
+ assertTrue("Should no timestamp diff in 100 billion tests", diff <= 0);
Review Comment:
billion → million
##########
flink-connectors/flink-connector-hbase-base/src/main/java/org/apache/flink/connector/hbase/util/HBaseTimestampGenerator.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+/** Generate timestamp for hbase mutation. */
Review Comment:
hbase → HBase
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ private static final Logger LOG = LoggerFactory.getLogger(HBaseTimestampGeneratorTest.class);
+
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
+ long now = timestampGenerator.get();
+ if (lastTimestamp > 0) {
+ assertTrue(lastTimestamp < now);
+ }
+ lastTimestamp = now;
+ }
+ final long realNow = timestampGenerator.getCurrentSystemTimeNano();
+ final long diff = lastTimestamp - realNow;
+ assertTrue("Should no timestamp diff in 100 billion tests", diff <= 0);
+ LOG.info(
+ "timestamp diff of 100 billion tests in nanosecond: {} (use {}, real {})",
Review Comment:
billion → million
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] lzshlzsh commented on a diff in pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "lzshlzsh (via GitHub)" <gi...@apache.org>.
lzshlzsh commented on code in PR #22612:
URL: https://github.com/apache/flink/pull/22612#discussion_r1199952569
##########
flink-connectors/flink-connector-hbase-base/src/test/java/org/apache/flink/connector/hbase/util/HBaseTimestampGeneratorTest.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.hbase.util;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertTrue;
+
+/** Tests for {@link HBaseTimestampGenerator}. */
+public class HBaseTimestampGeneratorTest {
+ private static final Logger LOG = LoggerFactory.getLogger(HBaseTimestampGeneratorTest.class);
+
+ @Test
+ public void testStronglyIncreasingTimestampGenerator() {
+ HBaseTimestampGenerator timestampGenerator = HBaseTimestampGenerator.stronglyIncreasing();
+ long lastTimestamp = 0;
+ for (int i = 0; i < 100_000_000; i++) {
+ long now = timestampGenerator.get();
+ if (lastTimestamp > 0) {
+ assertTrue(lastTimestamp < now);
Review Comment:
good advice
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] MartijnVisser commented on pull request #22612: [FLINK-32139][connector/hbase] Using strongly increasing nanosecond timestamp and DeleteColumn type to fix data accidental deletion and non deletion issues when sink hbase.
Posted by "MartijnVisser (via GitHub)" <gi...@apache.org>.
MartijnVisser commented on PR #22612:
URL: https://github.com/apache/flink/pull/22612#issuecomment-1578049705
> A friendly reminder: Please note the squish commit before merging and the commit message should start with [FLINK-JIRA_ID], thanks~
Hi @1996fanrui - Yeah I made a mistake, there's unfortunately nothing I can do to repair that situation :(
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org