Skip to content

Fix multithread writing for fragment result cache#16546

Merged
shixuan-fan merged 1 commit intoprestodb:masterfrom
superqtqt:fix/fragmentCacheWriteBug
Aug 12, 2021
Merged

Fix multithread writing for fragment result cache#16546
shixuan-fan merged 1 commit intoprestodb:masterfrom
superqtqt:fix/fragmentCacheWriteBug

Conversation

@superqtqt
Copy link
Contributor

@superqtqt superqtqt commented Aug 2, 2021

== RELEASE NOTES ==

General Changes
* Fix multithread writing for fragment result cache  #16455 
* add config `fragment-result-cache.max-single-pages-size` to control the max fragement cache file size

@superqtqt superqtqt force-pushed the fix/fragmentCacheWriteBug branch 2 times, most recently from 4df400f to 3dbb9c0 Compare August 3, 2021 02:14
@superqtqt
Copy link
Contributor Author

@shixuan-fan @kaikalur @highker @ajaygeorge @tdcmeehan
can you help me review the code

@superqtqt
Copy link
Contributor Author

@shixuan-fan can you help me merge the code

@tdcmeehan tdcmeehan requested a review from shixuan-fan August 3, 2021 14:48
Copy link
Contributor

@shixuan-fan shixuan-fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this. Overall looks good just some nits.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious: Does it make sense that instead of creating PagesSerde every time, we create only once in the constructor, and directly replace current pagesSerde

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, you could use something similar to the changes I made in Trino trinodb/trino#5545 which (mostly) puts the not thread safe buffers into a context object that can be created / released. I say "mostly" here because I didn't move the Compressor instance in which you would need to do in order to use it that way.

Another thing worth pointing out is that this implementation, as written, doesn't support encryption of the serialized pages.

Copy link
Contributor Author

@superqtqt superqtqt Aug 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shixuan-fan i have delete the write compress buffer and relation code.I find it not work.Can you help me approve

@pettyjamesm thanks for you advice .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shixuan-fan i have delete the write compress buffer and relation code.I find it not work.Can you help me approve

I'm trying to understand this. Do you mean you tried @pettyjamesm 's suggestion but it does not work?

@superqtqt superqtqt force-pushed the fix/fragmentCacheWriteBug branch 3 times, most recently from 8807909 to c31a85c Compare August 6, 2021 09:00
Copy link
Contributor

@pettyjamesm pettyjamesm Aug 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don’t want to catch Throwable here- since “should be fatal” members of the Error subheirarchy like OutOfMemoryError are not what you want to catch here. Seems like catching Exception would be sufficient instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes,I lack consideration.I hava fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider only extending it to RuntimeException? I don't think we should cover checked exception here.

Also, does it make sense to catch this separately from IOException and UncheckedIOException? There are legit reasons for them to happen, but maybe not for other exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you.

@superqtqt superqtqt force-pushed the fix/fragmentCacheWriteBug branch from c31a85c to 1b51083 Compare August 9, 2021 01:34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider only extending it to RuntimeException? I don't think we should cover checked exception here.

Also, does it make sense to catch this separately from IOException and UncheckedIOException? There are legit reasons for them to happen, but maybe not for other exceptions?

@shixuan-fan
Copy link
Contributor

Also, it might be great to add a test in TestFileFragmentResultCacheManager

@superqtqt superqtqt force-pushed the fix/fragmentCacheWriteBug branch 2 times, most recently from 936a293 to 2bf3c72 Compare August 10, 2021 13:10
Copy link
Contributor

@shixuan-fan shixuan-fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits on test. Mostly look good!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: threadCount. We don't use abbreviation in presto :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i hava add comment
and delete threadCnt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this? It's useful for debugging but not useful as a unit test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry ,i hava deleted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just returning true and false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok finish

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just checking if every future returns "success" (or true if applying previous comment). It might look neater :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok finish

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not move this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix,thank you

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create this as a local variable in the test method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix,thank you

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is purely nit, but maybe for (int i = 0; i < 10; i++) would be clearer? This way we don't need to declare i and threadCnt outside of the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious: is %s,%s enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i name it test write content,thread %s,%s,that i think it more clear

@superqtqt superqtqt force-pushed the fix/fragmentCacheWriteBug branch from 2bf3c72 to a1ab2db Compare August 11, 2021 06:44
@superqtqt
Copy link
Contributor Author

thank you for reviewing my code.I am the first time to commit code ,which wasting your time.

@superqtqt superqtqt force-pushed the fix/fragmentCacheWriteBug branch from a1ab2db to 5c0f19f Compare August 11, 2021 07:09
Copy link
Contributor

@shixuan-fan shixuan-fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

No need to apologize, you are the one doing the hard work and helping fixing stuff. We really appreciate that :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe revert the changes here and for SPLIT_2 if they are unintended.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

@shixuan-fan
Copy link
Contributor

Also, I'm wondering if we should change the commit and PR title to: "Fix multithread writing for fragment result cache"

@superqtqt superqtqt changed the title fix write cache bug when multithreading writing Fix multithread writing for fragment result cache Aug 12, 2021
@superqtqt superqtqt force-pushed the fix/fragmentCacheWriteBug branch from 5c0f19f to 5176668 Compare August 12, 2021 02:02
@superqtqt
Copy link
Contributor Author

Also, I'm wondering if we should change the commit and PR title to: "Fix multithread writing for fragment result cache"

ok ,i have changed

@shixuan-fan shixuan-fan merged commit fda59c3 into prestodb:master Aug 12, 2021
@shixuan-fan
Copy link
Contributor

Merged. Thanks for the help identifying/fixing bugs :)

@varungajjala varungajjala mentioned this pull request Aug 16, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants