Single user mode looses connection

So just a quick background, we are trying to update the database design, in a production environment. But we want to be sure, no users try to login during that time. So we started looking into single user mode, but that gave us some trouble, sometimes we would lose the connection in the middle of the update. So we setup a test environment to replicate the behavior.

We are using Microsoft SQL server 2017, with the AdventureWorks2017 database to replicate the issue. On the database we have turned off Auto close and Auto Update Statistics Asynchronously

If we then have two connections to the server, using the master database. Tell one of them to run this script

USE MASTER SET DEADLOCK_PRIORITY HIGH ALTER DATABASE [AdventureWorks2017] SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO  DECLARE @kill varchar(max) = ''; SELECT @kill = @kill + 'KILL ' + CONVERT(varchar(10), spid) + '; ' FROM master..sysprocesses  WHERE spid > 50 AND dbid = DB_ID('AdventureWorks2017') EXEC(@kill);  USE AdventureWorks2017 GO  DECLARE @cnt INT = 0; WHILE @cnt < 10000 BEGIN   SELECT TOP 1000 * from Person.Person;    SET @cnt = @cnt + 1; end; 

And then on the other repeatedly run

SELECT TOP 1000 * FROM AdventureWorks2017.Person.Person; GO; 

At some point the first script stops working, and complains with an error

Database ‘AdventureWorks2017’ is already open and can only have one user at a time.

But to our understanding, this should not happen cause it still has the connection. Note this doesn’t happen all the time. But it’s still fairly consistent.

Is there anything that we are missing, or can this be an issue with the SQL server?

Secure and private connection to GnuPG keyservers

I wish to privately submit my public key (without possibility of it’s snooping on the internet). I found that I have 3 ways to connect to the keyserver securely:

  1. https://
  2. hkps://
  3. hkp:// [Using TOR]

Which one of the 3 is most secure …….surprised to find that the TOR keyservers present use only hkp and not hkps?

https keyservers are working with ipv4 to search and submit keys but it’s hard to find hkps server working with ipv4?

Encryption (not hashing) of credentials in a Python connection string

I would like to know how to encrypt a database connection string in Python – ideally Python 3 – and store it in a secure wallet. I am happy to use something from pip. Since the connection string needs to be passed to the database connection code verbatim, no hashing is possible. This is motivated by:

  • a desire to avoid hard-coding the database connection credentials in a Python source file (bad for security and configurability);
  • avoid leaving them plain-text in a configuration file (not much better due to security concerns).

In a different universe, I have seen an equivalent procedure done in .NET using built-in machineKey / EncryptedData set up by aspnet_regiis -pe, but that is not portable.

Though this problem arises from an example where an OP is connecting via pymysql to a MySQL database,

  • the current question is specific neither to pymysql nor MySql, and
  • the content from that example is not applicable as a minimum reproducible example here.

The minimum reproducible example is literally

#!/usr/bin/env python3  PASSWORD='foo' 

Searching for this on the internet is difficult because the results I get are about storing user passwords in a database, not storing connection passwords to a database in a separate wallet.

I would like to do better than a filesystem approach that relies on the user account of the service being the only user authorized to view what is otherwise a plain-text configuration file.

Related questions

  • Securing connection credentials on a web server – but that requires manual intervention on every service start, which I want to avoid
  • Security while connecting to a MySQL database using PDO – which is PHP-specific and does not discuss encryption

Use of encrypting data in transit over a HTTPS connection

I find certain APIs (that provide sensitive information) using algorithms like ECDHE with X25519, on top of the already encrypted SSL connection. This compels us to use libraries like Tink (when we have to use it in Android Apps) that provides such algorithms, though the classes it provides us for using such algorithms is explicitly marked not to be used in production.

Is there any reason this could have use cases when transmitting sensitive information?

WordPress PHP custom function is causing 500 Internal Server Error Connection Timeout

I wrote a custom script to insert a post into WordPress and upload 3 images to the WP uploads directory.

To write the post I use the WP function wp_insert_post( $ wp_post_array, true );. Inside the script at various stages I also use wp_get_attachment_image_src($ image_id, $ size)[0];, wp_get_attachment_metadata($ image_id); and wp_get_attachment_image( $ image_id, 'large', false, $ image_attr ); but to upload the images and create their metadata I wrote this custom function below…

I must have messed up somewhere because I get a 500 Connection Timeout error when I run this code (even though it is only 3 images that are less than 1Mb each in size).

Can somebody spot what I am doing wrong? Thank you for your eyes and experience.

function insert_WP_Images_Data( $  post_id, $  image_url ) {  global $  writer_WP_id;  $  upload_dir = wp_upload_dir();  if ( isset($  image_url) && isset($  post_id) ) {      $  filename = basename($  image_url);     if(wp_mkdir_p($  upload_dir['path']))         $  file = $  upload_dir['path'] . '/' . $  filename;     else         $  file = $  upload_dir['basedir'] . '/' . $  filename;     $  image_data = file_get_contents( $  image_url );     file_put_contents($  file, $  image_data);      $  wp_filetype = wp_check_filetype($  filename, null);     $  attachment = array(     'post_author' => $  writer_WP_id,     'post_content' => '',     'post_title' => $  _SESSION['artist'],     'post_status' => 'inherit',     'post_name' => pathinfo($  image_url)['filename'],     'post_mime_type' => $  wp_filetype['type'],     'post_parent' => $  post_id,     'guid' => $  upload_dir['url'].'/'.$  filename     );     //  'post_title' => sanitize_file_name($  filename),      $  image_id = wp_insert_attachment( $  attachment, $  file, $  post_id );      require_once( ABSPATH.'wp-admin/includes/image.php' );     $  attach_data = wp_generate_attachment_metadata( $  image_id, $  file );     $  res1 = wp_update_attachment_metadata( $  image_id, $  attach_data );     $  res2 = set_post_thumbnail( $  post_id, $  image_id );      return $  image_id; } else {     echo '<span class="error">No post is selected or image is selected</span>'; } } 

I have already tried increasing my server execution time in cPanel (200, 600) and via .htaceess (300) but nothing works…

How does WordPress know wich language is chosen when there is a database connection error

When I have a db connection error in WordPress, WordPress shows the following error:

Error establishing a database connection

But when my website’s language is set to german, the message shows:

Fehler beim Aufbau einer Datenbankverbindung

Which is basically the same error message but in german. But how does WP know which language is chosen, since it could not connect to the database server?

LinkedIn connection marked unsafe

From time to time my LinkedIn connection gets marked as unsafe: no green lock next to the URL.

First, I believed this was a browser issue, but after I switched to another browser, the warning did not disappear (for now, my browsers are Opera and Chrome).

First, connection is always safe, but once I enter job search section and start scrawling through job offers, every now and then, although not often, the safe connection status turns into unsafe. Any one has an idea of what may cause such change?

Thanks for your attention.

The enclosed images further illustrate my question.

enter image description here

enter image description here

Can a malicious WIFI network force a connection

Say I enter a place with public WIFI. Of course, I would not connect to the network since I know it’s risky, but I do have my computer turned on. Can an attacker know my computer is there and force a connection to it? If they would be able to do so, than my precaution is wasted, and any attacks a malicious network could do would be done.

Telling me whether this could be done and how to stop it would be very helpful, thanks.

As a sidenote, connecting to a known network may not be safe either, could hackers “replace” an existing network with a malicious network with the same name? If so, how to protect myself against it?

Losing connection to the server when using PG Routing function pgr_alphaShapes

I am running PG Routing v. 3.0 on Postgresql 12.2 and the pgr_alphaShapes function is giving me a lot of trouble. Following the documentation here, I passed a geometry and a spoon radius.

SELECT *  FROM pgr_alphaShape( (SELECT ST_Collect(geom) FROM road_nodes), 1.5); 

When I run the query in pgAdmin 4, I get the following error:

Connection to the server has been lost. 

After getting this I ran my ST_Collect(geom) FROM road_nodes query with no problem. I tried running the query in DBeaver as well. There, I received the following error:

SQL Error [57P03]: FATAL: the database system is in recovery mode 

Clicking on “more details” reveals the following log:

org.jkiss.dbeaver.model.impl.jdbc.JDBCException: SQL Error [57P03]: FATAL: the database system is in recovery mode at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl.prepareStatement( at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl.prepareStatement( at org.jkiss.dbeaver.model.DBUtils.createStatement( at org.jkiss.dbeaver.model.DBUtils.makeStatement( at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeStatement( at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.lambda$  0( at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover( at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeSingleQuery( at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.extractData( at org.jkiss.dbeaver.ui.editors.sql.SQLEditor$  QueryResultsContainer.readData( at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$  0( at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover( at at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ at at Caused by: org.postgresql.util.PSQLException: FATAL: the database system is in recovery mode at org.postgresql.Driver$  ConnectThread.getResult( at org.postgresql.Driver.connect( at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.lambda$  0( at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.openConnection( at org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource.openConnection( at org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext.connect( at org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext.connect( at org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext.getConnection( at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl.getOriginal( at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl.prepareStatement( at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl.prepareStatement( ... 15 more 

I am unsure of what steps I should take next to get the function working.