-
Notifications
You must be signed in to change notification settings - Fork 53
Closed
Labels
Description
What happens?
Blobs retrieved from a result set before it's closed might return random values between GC calls.
To Reproduce
import java.sql.*;
import java.util.HexFormat;
public class DuckDBBlobTest {
public static void main(String[] args) throws Exception {
try (Connection connection = DriverManager.getConnection("jdbc:duckdb:")) {
try (Statement stmt = connection.createStatement()) {
Blob blob;
try (ResultSet resultSet = stmt.executeQuery("select 'AAAA'::blob")) {
resultSet.next();
blob = resultSet.getBlob(1);
}
String expected = HexFormat.of().formatHex(new byte[]{'A', 'A', 'A', 'A'});
for (int i = 0; i < 5000; i++) {
System.gc();
String actual = HexFormat.of().formatHex(blob.getBytes(0, Math.toIntExact(blob.length())));
if (!expected.equals(actual)) {
throw new SQLException("expected != actual: " + expected + " != " + actual);
}
}
}
}
}
}
Please note that this is a floating issue and might not reproduce immediately. Try running the sample multiple times. Eventually, you will see something like this:
expected != actual: 41414141 != 00000000
OS:
Windows 11 x64
DuckDB Version:
1.1.1
DuckDB Client:
Java JDBC / DBeaver 24.2.3
Hardware:
No response
Full Name:
Ian Vinogradov
Affiliation:
DBeaver
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a stable release
Did you include all relevant data sets for reproducing the issue?
Yes
Did you include all code required to reproduce the issue?
- Yes, I have
Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
- Yes, I have