Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@ protected Connection createNewConnection(long queryTimestamp) throws SQLExceptio
properties.setProperty("user", trinoUser);
if (config.isSinkMonitorFreshnessEmbedSnapshot())
{
String catalogName = "pixels";
String sessionPropValue = String.format("%s.query_snapshot_timestamp:%d", catalogName, queryTimestamp);
properties.setProperty("sessionProperties", sessionPropValue);
String catalog = parseCatalogFromUrl(trinoJdbcUrl);
if (catalog != null && catalog.equalsIgnoreCase("pixels"))
{
String sessionPropValue = String.format("%s.query_snapshot_timestamp:%d", catalog, queryTimestamp);
properties.setProperty("sessionProperties", sessionPropValue);
}
}
return DriverManager.getConnection(trinoJdbcUrl, properties);
}
Expand Down Expand Up @@ -410,4 +413,34 @@ private List<String> getStaticList()
{
return config.getSinkMonitorFreshnessEmbedTableList();
}

private String parseCatalogFromUrl(String url)
{
if (url == null || !url.startsWith("jdbc:trino://"))
{
return null;
}
String withoutProtocol = url.substring("jdbc:trino://".length());
int slashIndex = withoutProtocol.indexOf('/');
if (slashIndex == -1)
{
return null;
}
String remaining = withoutProtocol.substring(slashIndex + 1);

int nextSlash = remaining.indexOf('/');
int questionMark = remaining.indexOf('?');

int endIndex = remaining.length();
if (nextSlash != -1)
{
endIndex = nextSlash;
}
if (questionMark != -1 && questionMark < endIndex)
{
endIndex = questionMark;
}

return remaining.substring(0, endIndex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.pixelsdb.pixels.sink.util.MetricsFacade;
import io.pixelsdb.pixels.sink.util.rateLimiter.FlushRateLimiter;
import io.pixelsdb.pixels.sink.util.rateLimiter.FlushRateLimiterFactory;
import io.pixelsdb.pixels.sink.freshness.FreshnessClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -69,6 +70,7 @@ public void pollEvents(SinkProto.PollRequest request, StreamObserver<SinkProto.P
{
SchemaTableName schemaTableName = new SchemaTableName(request.getSchemaName(), request.getTableName());
LOGGER.debug("Received poll request for table '{}'", schemaTableName);
FreshnessClient.getInstance().addMonitoredTable(request.getTableName());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard FreshnessClient updates behind embed mode

Only embed mode starts and drains FreshnessClient (PixelsSinkApp calls freshnessClient.start() only when sink.monitor.freshness.level == "embed"), but this new unconditional call runs for every Flink poll request. In row/txn modes it still initializes the singleton and keeps adding table names to monitoredTables even though no scheduler cycle runs to clear them, which can accumulate state unnecessarily and can surface config-time failures from FreshnessClient in modes that should not depend on Trino settings.

Useful? React with 👍 / 👎.

List<SinkProto.RowRecord> records = new ArrayList<>(pollBatchSize);

try
Expand Down