-
Notifications
You must be signed in to change notification settings - Fork 73
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
Show completion estimate during backfill #567
Conversation
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.
Looks good, just left a comment about the retryable query.
@andrew-farries PTAL |
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 looks good 👍
We have tests for this package in db_test.go
; we should add tests for QueryContext
just as we have for ExecContext
:
Lines 22 to 62 in d64ba26
func TestExecContext(t *testing.T) { | |
t.Parallel() | |
testutils.WithConnectionToContainer(t, func(conn *sql.DB, connStr string) { | |
ctx := context.Background() | |
// create a table on which an exclusive lock is held for 2 seconds | |
setupTableLock(t, connStr, 2*time.Second) | |
// set the lock timeout to 100ms | |
ensureLockTimeout(t, conn, 100) | |
// execute a query that should retry until the lock is released | |
rdb := &db.RDB{DB: conn} | |
_, err := rdb.ExecContext(ctx, "INSERT INTO test(id) VALUES (1)") | |
require.NoError(t, err) | |
}) | |
} | |
func TestExecContextWhenContextCancelled(t *testing.T) { | |
t.Parallel() | |
testutils.WithConnectionToContainer(t, func(conn *sql.DB, connStr string) { | |
ctx := context.Background() | |
ctx, cancel := context.WithCancel(ctx) | |
// create a table on which an exclusive lock is held for 2 seconds | |
setupTableLock(t, connStr, 2*time.Second) | |
// set the lock timeout to 100ms | |
ensureLockTimeout(t, conn, 100) | |
// execute a query that should retry until the lock is released | |
rdb := &db.RDB{DB: conn} | |
// Cancel the context before the lock times out | |
go time.AfterFunc(500*time.Millisecond, cancel) | |
_, err := rdb.ExecContext(ctx, "INSERT INTO test(id) VALUES (1)") | |
require.Errorf(t, err, "context canceled") | |
}) | |
} |
Done |
Instead of only showing the number of rows backfills, show an estimate of the total number of tows completed as a percentage.
For example:
It attempts to estimate the total number of rows but will fall back to a full scan if the number of rows estimated is zero.
Closes #492