The Problem:
When I try to run gather stats over OpenVPN on my Oracle 19c database, SQL Developer doesn't return the typical "PL/SQL procedure successfully completed" message if it runs for more than a certain amount of time.
Apparently, the connection hangs after a while, and I either need to disconnect from OpenVPN or kill SQL Developer in Windows Task Manager to close it.
My Oracle 19c database and OpenVPN server are on different cloud providers.
Running gather stats on this database typically takes about half an hour.
Running the gather stats command on SQL Developer
What I checked:
Nothing unusual on the Iptables and OpenVPN logs on the OpenVPN Server or on the listener and alert logs on the Oracle 19c Server.
net.ipv4.tcp_keepalive_time and net.netfilter.nf_conntrack_tcp_timeout_established are set to their default values of 7200 (2 hours) and 432000 (5 days) on both machines.
If I connect to the database as system and run:
select x.sid, x.serial#, x.username, x.status, x.osuser, x.machine, x.program, x.event, x.state, sql.sql_text from v$sqlarea sql, v$session x where x.sql_hash_value = sql.hash_value and x.sql_address = sql.address and x.username = 'myuser';
After about half an hour, I noticed that the session for gather stats is inactive. So I assume that gather stats does indeed run and finish successfully, but just doesn’t return the aforementioned output message.
Gather stats running on the database
Gather stats session inactive after about half an hour
What I tried:
On a smaller database in the same instance, running gather stats over OpenVPN returns the aforementioned success message. This one takes around 10 minutes.
Connecting directly (without OpenVPN) to the database by adding my IP address to the firewall of the cloud provider and running gather stats also returns the aforementioned success message.
Generating a SSH public/private key pair on the Oracle 19c server and using SSH Hosts on SQL Developer, but the connection is very unstable/always resetting.
Setting up a Dante proxy server. Apparently, SQL Developer can only use some kind of special proxy server.
Setting up a IPSEC VPN with StrongSwan. My Windows 10 couldn't establish a connection with it for some reason.
First off, I was able to confirm that gather stats does indeed finish successfully by running:
After that I ran the following tcpdump commands on both servers:
And discovered that the Oracle 19c server did send the success message, but the OpenVPN server never received it.
After some digging around on various sites, I found out that I misunderstood what net.ipv4.tcp_keepalive_time actually does.
After that I found out about a network configuration of the cloud provider where I have my OpenVPN server hosted.
With this new information I got around this limitation by setting the keepalive time to a value inferior than 10 minutes by running the following command on the Oracle 19c server:
And made these changes permanent by saving them to /etc/sysctl.conf.
Finally, SQL Developer receives the success message and closes the connection.