hudi icon indicating copy to clipboard operation
hudi copied to clipboard

Deltastreamer -Global bloom Index resulting Duplicates across partitions for Same record Key

Open prashanthpdesai opened this issue 6 years ago • 14 comments

Tips before filing an issue

  • Have you gone through our FAQs? Yes

  • Join the mailing list to engage in conversations and get faster support at [email protected].

  • If you have triaged this as a bug, then file an issue directly.

Describe the problem you faced We are using Deltastreamer to read from topic and persist the data into HDFS location . enabled the GLOBAL_BLOOM index on COPY_ON_WRITE Storage Type with UPSERT mode, as our requirement is not to have duplicates across partitions ,but we are seeing duplicates for same record key across partitions .

We tried using two of the latest hudi utilities jars mentioned below , but the same result. hudi-utilities-bundle_2.11-0.6.0-SNAPSHOT.jar hudi-utilities-bundle_2.11-0.5.2-SNAPSHOT.jar

To Reproduce

Steps to reproduce the behavior:

1. 2. 3. 4.

Expected behavior

No Duplicates across partitions for the same record key.

Environment Description

  • Hudi version : 0.5.2

  • Spark version : 2.2.1

  • Hive version :

  • Hadoop version : Hadoop Version 2.7

  • Storage (HDFS/S3/GCS..) : HDFS

  • Running on Docker? (yes/no) : No

Additional context

Sample duplicate record :

scala> spark.sql("SELECT * FROM hudiTab where MBR_SYS_ID ='ABC:18:4587543:XZ:123456778'").show(5,false)
+-------------------+-------------------------+-------------------------------------------+----------------------+-----------------------------------------------------------------------+-------------------------------------------+-------+-------------+----------+-----------------------------------------------+
|_hoodie_commit_time|_hoodie_commit_seqno     |_hoodie_record_key                         |_hoodie_partition_path|_hoodie_file_name                                                      |MBR_SYS_ID                                 |INDV_ID|modifiedTs   |modifiedDt|indicators               |

|20200615211346     |20200615211346_24_1166263|ABC:18:4587543:XZ:123456778                |2020-06-15            |790b3252-c4f7-46ed-ad86-98877541b89b-0_24-22-717_20200615211346.parquet|ABC:18:4587543:XZ:123456778|                        |1592268506762|2020-06-15|[[2018-11-01,9999-12-31,N,Y,N,N,N,N,Y,1,1,Y,Y]]|
|20200616161512     |20200616161512_0_2586    |ABC:18:4587543:XZ:123456778                |2020-06-16            |3a47934b-ffb7-41f5-a9a4-6b4f40519e79-0_0-22-696_20200616161512.parquet |ABC:18:4587543:XZ:123456778|                        |1592339194660|2020-06-16|[[2018-11-01,9999-12-31,N,Y,N,N,N,N,Y,1,1,Y,Y]]|

Property file:

hoodie.datasource.write.recordkey.field=MBR_SYS_ID
hoodie.datasource.write.partitionpath.field=modifiedDt
hoodie.datasource.write.precombine.field=modifiedTs
hoodie.index.type=GLOBAL_BLOOM
hoodie.bloom.index.update.partition.path=true
hoodie.auto.commit=false
enable.auto.commit=false
hoodie.deltastreamer.kafka.source.maxEvents=10000000

#client.id=kaas.prod.elr.edzprod.mcm.hudi.new.cow
group.id=kaas.prod.elr.edzprod.mcm.hudi.cow.dedup.full.load
bootstrap.servers=xyyyyyyz:443
metadata.broker.list=xyyyyyyz:443
auto.offset.reset=earliest

Stacktrace our job is running every one hour reading from kafka topic and persisting into hudi dataset in HDFS location using deltastreamer . Total 117 Million data having 49K duplicate records on record key split across 5 partitions .

prashanthpdesai avatar Jun 17 '20 15:06 prashanthpdesai

@nsivabalan: Hi Sivabalan , we had worked with you last time on the similar kind of issue for test data ,you suggested to use new version of jar(0.5.2). we did use the new jar in production env , resulting duplicates for same record key across partitions , could you please have look and suggest if there anything missing from our end . 127 million total records have 49 K duplicated across 5 partitions in HDFS.

prashanthpdesai avatar Jun 17 '20 17:06 prashanthpdesai

@nsivabalan : Can you look into this when you get a chance ?

bvaradar avatar Jun 17 '20 18:06 bvaradar

@prashanthpdesai this is something we don’t typically hear about. Did you write to that table at any point using non global bloom and later switch?

vinothchandar avatar Jun 19 '20 04:06 vinothchandar

Could you check the spark UI and confirm that you have HoodieGlobalBloomIndex show up instead of HoodieBloomIndex?

vinothchandar avatar Jun 19 '20 04:06 vinothchandar

@nsivabalan i don’t recall fixing anything around this in 0.5.2. Was there a reason why you suggested that?

vinothchandar avatar Jun 19 '20 04:06 vinothchandar

yes, this should never be feasible unless you created a table as regular and then switched to global later. We have a unit test for the same exact case when we added the "update partition path" config. https://github.com/apache/hudi/blob/master/hudi-client/src/test/java/org/apache/hudi/index/bloom/TestHoodieGlobalBloomIndex.java Check for testTagLocationWhenShouldUpdatePartitionPath . @vinothchandar : I don't think I suggested to try out 0.5.2 with the intention that we had some fixes. And guess last time the question was bit different.

nsivabalan avatar Jun 19 '20 11:06 nsivabalan

Hi @vinothchandar @nsivabalan : Thank you for checking , No we didn't write table anytime using Bloom index , we wrote as Global Bloom from Beginning . Please find the attached spark UI , which is using Global bloom.

image

as mentioned in the above thread , the data is partitioned on modified_dt we expect to delete the record key present in the older partition (2020-06-15) .

prashanthpdesai avatar Jun 19 '20 14:06 prashanthpdesai

@prashanthpdesai to help narrow this one down (given its tricky), are you convinced that this happens when the modified_dt actually changed? is it the same keys duplicated every time . is it possible to trim the input down to those keys and give us a reproducible test case?

Also checked that nothing much has changed around this.. https://github.com/apache/hudi/blame/master/hudi-client/src/main/java/org/apache/hudi/index/bloom/HoodieGlobalBloomIndex.java#L123

for the kicks of it, also please see if you can just using master branch?.. (I don't expect it to change; just to rule things out)

vinothchandar avatar Jun 21 '20 14:06 vinothchandar

@vinothchandar : Yes Vinoth ,we are using current date as our modified_dt , just pulled the latest record from recent run , which we started on 19th , have 3 partitions 19th, 20th and 21st run.

FYI: Input is kafka topic with avro format in it.

scala> spark.sql("select * from hudimcmfulldumpnew where _hoodie_record_key='abc:19:YYY:XZ:12345678").show(false)

|_hoodie_commit_time|_hoodie_commit_seqno |_hoodie_record_key |_hoodie_partition_path|_hoodie_file_name |MBR_SYS_ID |INDV_ID|modifiedTs |modifiedDt|indicators | |20200619111141 |20200619111141_5_224791|abc:19:YYY:XZ:12345678|2020-06-19|8c72d601-48e9-46c7-bd16-8e49f15dd63b-0_5-22-569_20200619111141.parquet|abc:19:YYY:XZ:12345678| |1592580775819|2020-06-19|[[2016-10-01,2019-03-31,Y,Y,N,N,N,N,N,Y,Y,Y,1,1,1]]| |20200621030755 |20200621030755_0_26958 |abc:19:YYY:XZ:12345678|2020-06-21|ff35e455-6bb9-4882-9fce-8c8f3a8a1677-0_0-22-582_20200621030755.parquet|abc:19:YYY:XZ:12345678| |1592726093365|2020-06-21|[[2016-10-01,2019-03-31,Y,Y,N,N,N,N,N,Y,Y,Y,1,1,1]]|

pdesai@edgenode:/***/datalake/xxx/yyy/prd/mcm/mcm_hudi_cow_dedup_full_load_fix $ ls -ltr total 2 drwxr-sr-x. 2 xxx yyy 11 Jun 21 04:07 2020-06-21 drwxr-sr-x. 2 xxx yyy 20 Jun 21 04:08 2020-06-19 drwxr-sr-x. 2 xxx yyy 6 Jun 21 04:08 2020-06-20

have attached the .hoodie commit time for **20200621030755

committime (1).docx

prashanthpdesai avatar Jun 21 '20 23:06 prashanthpdesai

@prashanthpdesai - i think you need to use below property along with global bloom. Have you tried this?

bloomIndexUpdatePartitionPath(updatePartitionPath = false)Permalink Property: hoodie.bloom.index.update.partition.path Only applies if index type is GLOBAL_BLOOM. When set to true, an update including the partition path of a record that already exists will result in inserting the incoming record into the new partition and deleting the original record in the old partition. When set to false, the original record will only be updated in the old partition.

rvd8345 avatar Jul 02 '20 19:07 rvd8345

@rvd8345 thanks for chiming in.. I think there might be a bug where the deletion on old partition is not propagating correctly.. Will update once we have a better resolution.. It was tricky.. but we are making progress.. :)

vinothchandar avatar Jul 02 '20 20:07 vinothchandar

now that we have the PR up.. closing this.

vinothchandar avatar Jul 07 '20 23:07 vinothchandar

Can you link a pr for this issue? @vinothchandar

mingujotemp avatar Aug 04 '20 07:08 mingujotemp

https://github.com/apache/hudi/pull/1793

nsivabalan avatar Aug 04 '20 11:08 nsivabalan