-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quantize revisions for memdb, postgres datastores #527
Conversation
f8d93dc
to
828478d
Compare
if quantizationPeriodNanos < 1 { | ||
quantizationPeriodNanos = 1 | ||
} | ||
revisionQuery := fmt.Sprintf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since most of the parameters are "static", could we somehow include them above and only parameterize on the quantizationPeriodNanos
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only done once at initialization time.
revisionTx := transactionFromRevision(revision) | ||
offset := uint64(pgd.gcWindowInverted.Seconds()) | ||
|
||
queryValid := fmt.Sprintf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question re: parameterization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can fill in most of them at initialization time, and then pass one as an arg.
|
||
queryValid := fmt.Sprintf( | ||
queryValidTransaction, | ||
revisionTx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any way we could escape the revisionTx such that if it does contain SQL, it won't cause a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's an int, how could it contain sql?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason I thought it was a string
} | ||
|
||
func createNewTransaction(ctx context.Context, tx pgx.Tx) (newTxnID uint64, err error) { | ||
ctx, span := tracer.Start(ctx, "computeNewTransaction") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the name of the span
@@ -61,6 +55,20 @@ const ( | |||
tracingDriverName = "postgres-tracing" | |||
|
|||
batchDeleteSize = 1000 | |||
|
|||
querySelectRevision = ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind adding a comment here explaining each of the queries?
828478d
to
57babc5
Compare
|
||
// querySelectRevision will round the database's timestamp down to the nearest | ||
// quantization period, and then find the first transaction after that. If there | ||
// are no transactions newer than the quantization period, it just picks the last |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last -> latest
6bb3497
to
198abd1
Compare
// querySelectRevision will round the database's timestamp down to the nearest | ||
// quantization period, and then find the first transaction after that. If there | ||
// are no transactions newer than the quantization period, it just picks the latest | ||
// transaction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add period at end of comment
// are no transactions newer than the quantization period, it just picks the latest | ||
// transaction | ||
querySelectRevision = ` | ||
SELECT COALESCE( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether we should have a test that explicitly runs these queries and validates their outputs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
198abd1
to
2706bd2
Compare
2706bd2
to
d833f98
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
582f669
to
a3cfd42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.