Oracle Deadlock When Using Bitmap Index

When using bitmap indexes in Oracle database one must watch out for deadlocks, see for example Tom Kyte‘s remark on Bitmap indexes and locking. This is by design of bitmap indexes. Below example is given in Oracle Bitmap Indexes Limitations/Restrictions.

Problem occurs on “Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production”.

create table X (a char(1));
create bitmap index Xix on X(a);
insert into X select decode(mod(rownum,2),0,'A','B') from All_Objects;

Open two session, i.e., open SQL*Plus two times.

Session 1 Session 2
insert into X values(‘A’)
insert into X values(‘B’)
insert into X values(‘B’)
deadlock insert into X values(‘A’)

Updating IP Address in Dynu

Dynu is a free dynamic DNS service. As described in Microsoft Brought Down No-IP.org I have to cope with big business just pushing their own interest and not caring on small business or private customers.

I tried to update IP address for Dynu using ddclient using package ddclient. This failed. The version 2 of Dynu’s API allows to do that with curl/wget.

Steps to set it up:

  1. Go to API Credentials to get your “API-key”
  2. Go to API and authorize using your “API-key”
  3. Run first “GET /dns” to gather your so called “id”. Alternatively, run the below curl command

The curl command to get your “id” is as follows:

curl -X GET "https://api.dynu.com/v2/dns" -H  "accept: application/json" -H  "API-Key: yyyyyyyyyy"

Output is like this:

{"statusCode":200,"domains":[{"id":12345678,"name":"eklausmeier.mywire.org","unicodeName":"eklausmeier.mywire.org","token":"aaaaaaaaa","state":"Complete","location":"office","group":"office","ipv4Address":"109.90.226.205","ipv6Address":null,"ttl":90,"ipv4":true,"ipv6":false,"ipv4WildcardAlias":false,"ipv6WildcardAlias":false,"createdOn":"2019-05-25T08:37:16","updatedOn":"2019-06-29T12:33:04.707"}]}%

Once you know your “API-key” and “id” you can set-up a simple script to run periodically. I use a Perl script which first fetches my current internet address, $remoteIP, and then updates Dynu.

open(F,"curl -sX POST \"https://api.dynu.com/v2/dns/XXXXXXXX\" "
        . "-H \"accept: application/json\" "
        . "-H \"API-Key: yyyyyyyyyyyyyyyyyyyyyyyy\" "
        . "-H \"Content-Type: application/json\" "
        . "-d \"{\\\"name\\\":\\\"eklausmeier.mywire.org\\\","
                . "\\\"group\\\":\\\"office\\\","
                . "\\\"ipv4Address\\\":\\\"${remoteIP}\\\","
                . "\\\"ttl\\\":90,\\\"ipv4\\\":true}\" |")
        || die("Cannot curl to dynu.com");
while (<F>) {
        print;
}
close(F) || die("Cannot close dynu.com");

If all goes well then output is:

{"statusCode":200}

Google Chrome in Android Cannot Clear Cookies

Google Chrome on Android version 74.0.3729 can no longer clear history, cookies, local data, etc. See screenshot below.

Even when this process is running completely uninterrupted, nothing happens. I.e., changing display sleep time to 30 minutes, Google Chrome will not finish.

Problem solution: Shut down phone. Power up again, and try again to delete cookies. This time it worked. Seems that some Android Chrome internal locking and contention blocked deletion.

Showing History of Visits in Mozilla Firefox

If one needs to know when some website has been visited in Mozilla Firefox then go to the default directory and open the places.sqlite file:

cd ~/.mozilla/firefox/<xyz>.default/
sqlite3 places.sqlite

Issue below SQL command

select visit_date,
       datetime(visit_date/1000000, 'unixepoch','localtime') as S
from moz_historyvisits
where place_id in
       (select id from moz_places where url like 'https://www.google.come%')
and S like '2019-01-2%'
order by S;

References:

  1. How do I decode the Last_Date_ Visited field in the places.sqlite db?
  2. SQLite: Date And Time Functions
  3. Entity relationship diagram of tables: The Places database

ER diagram looks like this:
ER diagram

Added 30-Jun-2019: Interesting comment from Ronald Scheckelhoff from 19-May-2019 on caching DNS entries of previously visited URLs.

… could use this database to collect an overall sample of my web surfing habits, and then plug that data into something like the Unbound DNS resolver to do my own DNS lookups for the places I usually visit. I was doing that with Squid, but it has some limitations for my situation. Maybe this is better (plus, I don’t have to use Squid).

java.sql.SQLRecoverableException: IO Error: Connection reset by peer, Authentication lapse

I encountered the following error, when I wanted to connect to Oracle v12.2.0.1.0 database with Java 1.8.0_192-b26:

java.sql.SQLRecoverableException: IO Error: Connection reset by peer, Authentication lapse 321631 ms.

This was unexpected as the same program did run absolutely fine on another Linux machine. Program in question is

import java.sql.Connection;
import java.sql.SQLException;

import oracle.jdbc.pool.OracleDataSource;

public class OraSample1 {

        public static void main (String argv[]) {
                System.out.println("Starting...");
                try {
                        OracleDataSource ds = new OracleDataSource();
                        ds.setURL("jdbc:oracle:thin:@nuc:1521:orcl");
                        Connection conn=ds.getConnection("c##klm","klmOpRisk");
                        System.out.println("Connected");
                } catch (SQLException e) {
                        System.out.println(e);
                }
        }

}

Solution: Add the following property setting to command line

java -Djava.security.egd=file:/dev/urandom OraSample1

Also see “java.sql.SQLException: I/O Error: Connection reset” in linux server [duplicate] on Stackoverflow,