Skip to content

Commit

Permalink
WIP: debug test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
josephschorr committed Dec 10, 2024
1 parent d5c323b commit 62c8697
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
5 changes: 4 additions & 1 deletion internal/datastore/postgres/locks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package postgres

import "context"
import (
"context"
)

type lockID uint32

Expand All @@ -19,6 +21,7 @@ func (pgd *pgDatastore) tryAcquireLock(ctx context.Context, lockID lockID) (bool
if err := row.Scan(&lockAcquired); err != nil {
return false, err
}

return lockAcquired, nil
}

Expand Down
32 changes: 16 additions & 16 deletions internal/datastore/postgres/postgres_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
b := testdatastore.RunPostgresForTesting(t, "", config.targetMigration, config.pgVersion, config.pgbouncer)
ctx := context.Background()

test.AllWithExceptions(t, test.DatastoreTesterFunc(func(revisionQuantization, gcInterval, gcWindow time.Duration, watchBufferLength uint16) (datastore.Datastore, error) {
test.AllWithExceptions(t, test.DatastoreTesterFunc(func(revisionQuantization, _, gcWindow time.Duration, watchBufferLength uint16) (datastore.Datastore, error) {
ds := b.NewDatastore(t, func(engine, uri string) datastore.Datastore {
ds, err := newPostgresDatastore(ctx, uri, primaryInstanceID,
RevisionQuantization(revisionQuantization),
GCWindow(gcWindow),
GCInterval(gcInterval),
GCInterval(veryLargeGCInterval),
WatchBufferLength(watchBufferLength),
DebugAnalyzeBeforeStatistics(),
MigrationPhase(config.migrationPhase),
Expand Down Expand Up @@ -153,7 +153,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
RevisionInversionTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(1),
MigrationPhase(config.migrationPhase),
))
Expand All @@ -163,7 +163,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
ConcurrentRevisionHeadTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(1),
MigrationPhase(config.migrationPhase),
))
Expand All @@ -173,7 +173,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
ConcurrentRevisionWatchTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(50),
MigrationPhase(config.migrationPhase),
))
Expand All @@ -183,7 +183,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
OverlappingRevisionWatchTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(50),
MigrationPhase(config.migrationPhase),
))
Expand All @@ -193,7 +193,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
RepairTransactionsTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(1),
MigrationPhase(config.migrationPhase),
))
Expand All @@ -203,7 +203,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
NullCaveatWatchTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(50),
MigrationPhase(config.migrationPhase),
))
Expand All @@ -213,7 +213,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
RevisionTimestampAndTransactionIDTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(50),
MigrationPhase(config.migrationPhase),
))
Expand All @@ -223,7 +223,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
CheckpointsOnOutOfBandChangesTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(50),
MigrationPhase(config.migrationPhase),
))
Expand All @@ -233,7 +233,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
SerializationErrorTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(50),
MigrationPhase(config.migrationPhase),
))
Expand All @@ -243,7 +243,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
StrictReadModeTest,
RevisionQuantization(0),
GCWindow(1000*time.Second),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(50),
MigrationPhase(config.migrationPhase),
ReadStrictMode(true),
Expand All @@ -254,7 +254,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
LockingTest,
RevisionQuantization(0),
GCWindow(1000*time.Second),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(50),
MigrationPhase(config.migrationPhase),
))
Expand All @@ -265,7 +265,7 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
OTelTracingTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(1*time.Hour),
GCInterval(veryLargeGCInterval),
WatchBufferLength(1),
MigrationPhase(config.migrationPhase),
))
Expand All @@ -285,12 +285,12 @@ func testPostgresDatastoreWithoutCommitTimestamps(t *testing.T, pc []postgresCon

// NOTE: watch API requires the commit timestamps, so we skip those tests here.
// NOTE: gc tests take exclusive locks, so they are run under non-parallel.
test.AllWithExceptions(t, test.DatastoreTesterFunc(func(revisionQuantization, gcInterval, gcWindow time.Duration, watchBufferLength uint16) (datastore.Datastore, error) {
test.AllWithExceptions(t, test.DatastoreTesterFunc(func(revisionQuantization, _, gcWindow time.Duration, watchBufferLength uint16) (datastore.Datastore, error) {
ds := b.NewDatastore(t, func(engine, uri string) datastore.Datastore {
ds, err := newPostgresDatastore(ctx, uri, primaryInstanceID,
RevisionQuantization(revisionQuantization),
GCWindow(gcWindow),
GCInterval(gcInterval),
GCInterval(veryLargeGCInterval),
WatchBufferLength(watchBufferLength),
DebugAnalyzeBeforeStatistics(),
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/datastore/test/revisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func RevisionGCTest(t *testing.T, tester DatastoreTester) {
gcable, ok := ds.(common.GarbageCollector)
if ok {
gcable.ResetGCCompleted()
require.Eventually(func() bool { return gcable.HasGCRun() }, 10*time.Second, 100*time.Millisecond, "GC was never run as expected")
require.Eventually(func() bool { return gcable.HasGCRun() }, 5*time.Second, 50*time.Millisecond, "GC was never run as expected")
}

// FIXME currently the various datastores behave differently when a revision was requested and GC Window elapses.
Expand Down

0 comments on commit 62c8697

Please sign in to comment.