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 @@ -91,6 +91,11 @@ public boolean isCompressEnabled() {
return compress;
}

@Override
public boolean allowCloseChannel() {
return true;
}

@Override
public CompressAlgorithm getCompressAlgorithm() {
return new CompressAlgorithm() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public class DefaultProxyConfig extends AbstractConfigBean implements ProxyConfi

private static final String KEY_CROSS_REGION_TRAFFIC_CONTROL_LIMIT = "proxy.cross.region.traffic.control.limit";

private static final String ALLOW_CLOSE_CHANNEL = "proxy.allow.close.channel";

public DefaultProxyConfig() {
CompositeConfig compositeConfig = new CompositeConfig();
compositeConfig.addConfig(Config.DEFAULT);
Expand Down Expand Up @@ -215,4 +217,9 @@ public boolean isCrossRegionTrafficControlEnabled() {
public long getCrossRegionTrafficControlLimit() {
return getLongProperty(KEY_CROSS_REGION_TRAFFIC_CONTROL_LIMIT, 200 * 1024 * 1024L); // 100MB/s default
}

@Override
public boolean allowCloseChannel() {
return getBooleanProperty(ALLOW_CLOSE_CHANNEL, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@ public interface ProxyConfig extends TLSConfig {
*/
long getCrossRegionTrafficControlLimit();

/**
* DRC does not allow the proxy to actively close the channel during backpressure.
* @return true if allowing the proxy to actively close the connection, false otherwise.
*/
boolean allowCloseChannel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ protected void check() {
long maxBlockWait = config.getBlockWaitBaseMill() + DefaultProxyServer.WRITE_HIGH_WATER_MARK / config.getBlockWaitRate();
long localFrontendBlockFrom = frontendBlockFrom.get();
long localBackendBlockFrom = backendBlockFrom.get();
if (localFrontendBlockFrom > 0 && current - localFrontendBlockFrom > maxBlockWait) {
if (localFrontendBlockFrom > 0 && current - localFrontendBlockFrom > maxBlockWait && config.allowCloseChannel()) {
logger.warn("[check][frontendLongBlock][{}] close", current - localFrontendBlockFrom);
frontend.release();
} else if (localBackendBlockFrom > 0 && current - localBackendBlockFrom > maxBlockWait) {
} else if (localBackendBlockFrom > 0 && current - localBackendBlockFrom > maxBlockWait && config.allowCloseChannel()) {
logger.warn("[check][backendLongBlock][{}] close", current - localBackendBlockFrom);
backend.release();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,9 @@ public TestProxyConfig setStartMonitor(boolean startMonitor) {
public void setCompress(boolean compress) {
this.compress = compress;
}

@Override
public boolean allowCloseChannel() {
return true;
}
}