Skip to content

Enhancement: failing concurrent transactions - #193

Merged
gontarzpawel merged 6 commits into
masterfrom
fix/concurrent-query-failing
Sep 5, 2022
Merged

gontarzpawel merged 6 commits into
masterfrom
fix/concurrent-query-failing

Conversation

@gontarzpawel

Copy link
Copy Markdown
Contributor

Description

Mark transaction registry record as failed, upon query failure, only for non-recoverable status codes.

Created to trigger discussion.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe): Enhancement

Checklist

  • Linter passes correctly
  • Add tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary

Does this introduce a breaking change?

  • Yes
  • No

Further comments

@render

render Bot commented Jul 20, 2022

Copy link
Copy Markdown

Comment thread proxy.go Outdated
}
}

var clickhouseNonRecoverableStatusCodes = map[int]struct{}{400: {}, 404: {}, 500: {}}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

cf our discussion on slack. There is at least the 408 code that is missing and is very important. And maybe doing a list of clickhouseRecoverableStatusCodes instead of clickhouseNonRecoverableStatusCodes might be safer

@mga-chka
mga-chka self-requested a review August 22, 2022 07:39
@gontarzpawel
gontarzpawel force-pushed the fix/concurrent-query-failing branch from 4f746b8 to 662477d Compare September 3, 2022 11:24
@gontarzpawel
gontarzpawel force-pushed the fix/concurrent-query-failing branch from 662477d to 594358d Compare September 3, 2022 11:27
@gontarzpawel
gontarzpawel force-pushed the fix/concurrent-query-failing branch from 594358d to 9cb316e Compare September 3, 2022 11:29
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Sep 4, 2022
Comment thread proxy.go Outdated

// clickhouseRecoverableStatusCodes set of recoverable http responses' status codes from Clickhouse.
// When such happens we mark transaction as completed and let concurrent query to hit another Clickhouse shard.
var clickhouseRecoverableStatusCodes = map[int]struct{}{503: {}}

@mga-chka mga-chka Sep 5, 2022 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A bit opinionated but instead of 503 you should create a const variable with a meaningFull name like httpServiceUnavailable and put this variable in your map (maybe such a constant already exist in the net.http package)

open questions:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

http.StatusServiceUnavailable used, thanks!

Regarding open questions:

  • let's follow up on this if such need will raise. I'm unsure about it
  • enriched the doc 👌

Comment thread main_test.go

go func() {
defer wg.Done()
time.Sleep(20 * time.Millisecond)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why do we need to sleep for 20 msec. Our logic of conccurence query should work even if we don't sleep

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in case the start up of the first go routine (the one that's supposed to be launched first) takes longer than the 2nd. In an unstable/slow environment, such as CI we use, it's very likely to happen

Comment thread main_test.go
// scenario: 1st query fails before grace_time elapsed. 2nd query fails as well.

q := "SELECT RECOVERABLE-ERROR"
executeTwoConcurrentRequests(t, q, http.StatusServiceUnavailable, http.StatusServiceUnavailable, "DB::Unavailable\n", "DB::Unavailable\n")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

@gontarzpawel
gontarzpawel merged commit b459dcc into master Sep 5, 2022
@gontarzpawel
gontarzpawel deleted the fix/concurrent-query-failing branch September 5, 2022 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants