diff --git a/server.go b/server.go index 5decc92..29bdd76 100644 --- a/server.go +++ b/server.go @@ -106,8 +106,8 @@ type Server struct { draining bool } - sqlMemoryPool mon.MemoryMonitor - connMonitor mon.MemoryMonitor + sqlMemoryPool mon.BytesMonitor + connMonitor mon.BytesMonitor } // ServerMetrics is the set of metrics for the pgwire server. @@ -150,7 +150,7 @@ func MakeServer( cfg *base.Config, executor *sql.Executor, internalMemMetrics *sql.MemoryMetrics, - parentMemoryMonitor *mon.MemoryMonitor, + parentMemoryMonitor *mon.BytesMonitor, histogramWindow time.Duration, ) *Server { server := &Server{ @@ -160,12 +160,14 @@ func MakeServer( metrics: makeServerMetrics(internalMemMetrics, histogramWindow), } server.sqlMemoryPool = mon.MakeMonitor("sql", + mon.MemoryResource, server.metrics.SQLMemMetrics.CurBytesCount, server.metrics.SQLMemMetrics.MaxBytesHist, 0, noteworthySQLMemoryUsageBytes) server.sqlMemoryPool.Start(context.Background(), parentMemoryMonitor, mon.BoundAccount{}) server.connMonitor = mon.MakeMonitor("conn", + mon.MemoryResource, server.metrics.ConnMemMetrics.CurBytesCount, server.metrics.ConnMemMetrics.MaxBytesHist, int64(connReservationBatchSize)*baseSQLMemoryBudget, noteworthyConnMemoryUsageBytes) diff --git a/v3.go b/v3.go index f8794e1..d33f342 100644 --- a/v3.go +++ b/v3.go @@ -186,11 +186,11 @@ type v3Conn struct { metrics *ServerMetrics - sqlMemoryPool *mon.MemoryMonitor + sqlMemoryPool *mon.BytesMonitor } func makeV3Conn( - conn net.Conn, metrics *ServerMetrics, sqlMemoryPool *mon.MemoryMonitor, executor *sql.Executor, + conn net.Conn, metrics *ServerMetrics, sqlMemoryPool *mon.BytesMonitor, executor *sql.Executor, ) v3Conn { return v3Conn{ conn: conn, diff --git a/v3_test.go b/v3_test.go index 8e3624d..efa8942 100644 --- a/v3_test.go +++ b/v3_test.go @@ -35,7 +35,9 @@ import ( func makeTestV3Conn(c net.Conn) v3Conn { metrics := makeServerMetrics(nil, metric.TestSampleInterval) - mon := mon.MakeUnlimitedMonitor(context.Background(), "test", nil, nil, 1000) + mon := mon.MakeUnlimitedMonitor( + context.Background(), "test", mon.MemoryResource, nil, nil, 1000, + ) exec := sql.NewExecutor( sql.ExecutorConfig{ AmbientCtx: log.AmbientContext{Tracer: tracing.NewTracer()},