Insert in tx #51
No reviewers
Labels
No labels
area: devops
area: discovery
area: docs
area: livestream
area: proposal
consider soon
dependencies
Epic
good first issue
hacktoberfest
help wanted
icebox
level: 1
level: 2
level: 3
level: 4
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
on hold
priority: blocker
priority: high
priority: low
priority: medium
resilience
Tom's Wishlist
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/reflector.go#51
Loading…
Reference in a new issue
No description provided.
Delete branch "insert_in_tx"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
my version of @shyba's #50. see which you like better (or maybe you'll have an even better idea?)
wrap blob insertion in tx. fixes lbryio/lbry-sdk#3296
The problem is that inserting an sd blob with ~5k
blobs takes longer than 30 seconds. So the client
times out and retries the request. At that point,
reflector is not done inserting so it replies with
a smaller number of blobs than it should. The client
uploads that many blobs and marks the stream as
reflected. The remaining blobs never get uploaded.
Victor says doing the insert inside a transaction should be
faster than doing 10k (2 per blob) inserts
independently.
He's also doing a client-side fix for this.
client side fix at https://github.com/lbryio/lbry-sdk/pull/3308
if we can make that faster it should also help not having incomplete data on shutdown.
I had a similar issue on the SDK some years ago and using a transaction was absurdly faster, but I don't know how much that replicates to MySQL
why not declare it at the outer level?
Would not name this
ifaces
... saving four bytes overinterfaces
isn't worth the cognitive load.What's the benefit of just logging and re-panicking here and below? I would just return a wrapped error, i.e.
I'm in favor of this implementation. Aside from a few nitpicks, I don't have any qualms with it.
because its not meant for use outside that function. but i could move it if you want
👍
Not sure I can explain it but it just feels dirty to have an inline type definition, plus this one had an uppercase name so felt like a typo.
made them lowercase
it might feel dirty because Python is OO and interfaces are always declared alongside objects and explicitly implemented by those objects. in Go, otoh, types can implement interfaces that they know nothing about. if i define a struct and it has a
Read(p []byte) (n int, err error)
method, then it implementsio.Reader
. it does not need to know thatio.Reader
exists. In fact I could define agrin.StoryReader
interface in a completely unrelated project and my struct will implement that too if the methods match.does that make it feel better?
ref: https://golang.org/ref/spec#Interface_types
Interfaces are too bleeding edge in Python for me to be familiar with them, from what I gather they've only been added last year with protocols PEP.
My general feeling instead was that meta-objects aka types are better declared namespace-wide (= package-wide in case of golang) unless we're dealing with tests.
Is it actually not possible to declare this as
func Begin(db beginner) (Transactor, error)
? We seem to be returningTransactor
regardless.we probably can. this is more generic and i copied it from elsewhere but you're prolly right that we can just slim it down for us
actually it doesn't work with
beginner
because we're passing it a*sql.DB
which is ansqlBeginner
. so we can maybe support just the latter.Pull request closed