Mar 29, 2025

Mongo DB Connect String

  1. Standard format
    • Used to connect to standalone clusters, replica sets, or shared clusters
    • mongodb+srv://<username>:<password>@cluster0.e4fwa7d.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0
  2. DNS seed list format 
    • Provides a DNS server list to connection string

Dec 29, 2023

Gradle version update from 6.5 to 8.1.1 findings.

Here is the list of changes required on Gradle upgrade from version 6.5 to 8.1.1

1. Replace xml.enabled to xml.required in reports of jacocoTestReport
jacocoTestReport {
    reports {
                xml.enabled = true //replace with xml.required = true
                ....
            }
        } 


2. Replace the depreciated properties with new properties as mentioned below:

  • appendix  -> archiveAppendix
  • archiveName -> archiveFileName (archivePath)
  • baseName -> archiveBaseName
  • classifier -> archiveClassifier
  • destinationDir -> destinationDirectory
  • extension -> archiveExtension
  • version -> archiveVersion

3. Replace implementation's force with version

            implementation (' ... ') {
                force = true // replace with version(true)
            }

4. Comment/remove all @Override

5. Replace all compile (' ... ') dependencies with implementation(' ... ')

 

Aug 18, 2022

Useful links

 https://regex101.com/



Regular expression to remove value from JSON output.

Jul 22, 2022

How to change timezone for OCI Linux using command line.

  • $ timedatectl
  • $ timedatectl list-timezones
  • $ sudo timedatectl set-timezone <your_time_zone>
    • eg. sudo timedatectl set-timezone Asia/Kolkata
  • To verify the change, invoke the timedatectl command again:
    • $ timedatectl

Jun 1, 2022

Basic Jenkins Setup

  1. Download the Jenkins war (LTS) file from https://www.jenkins.io/download/
  2. Setup JDK 11+ and set java to the path environment variable.
  3. Set JENKINS_HOME to any directory
  4. Run >java -jar jenkins.war
  5. Access Jenkins Server @ http://localhost:8080

  6. Provide Administrator password, generated at highlight path above.
  7. Proceed with 'Install suggested plugins.

Steps to open firewall port to access Jenkins server.
YOURPORT=8080
PERM="--permanent"
SERV="$PERM --service=jenkins"

firewall-cmd $PERM --new-service=jenkins
firewall-cmd $SERV --set-short="Jenkins ports"
firewall-cmd $SERV --set-description="Jenkins port exceptions"
firewall-cmd $SERV --add-port=$YOURPORT/tcp
firewall-cmd $PERM --add-service=jenkins
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload

May 24, 2022

Kafka Commands for Windows

  1. bin/windows/zookeeper-server-start.bat ./config/zookeeper.properties -to start zookeeper
  2. bin/windows/kafka-server-start.bat ./config/server.properties -to start Kafka server
  3. bin/windows/kafka-topics.bat --create --topic <topic_name> --bootstrap-server "127.0.0.1:9092"

May 10, 2022

Feb 9, 2022

How to Reduce Long GC Pauses

 

Source: https://dzone.com/articles/how-to-reduce-long-gc-pause

Garbage collection is necessary, but it can be a performance killer if not done well. Take these steps to make sure your GC pauses are minimal and short.

Long GC pauses are undesirable for applications. It affects your SLAs, it results in poor customer experiences, and it causes severe damages to mission-critical applications. Thus, in this article, I have laid out key reasons that can lead to long GC pauses as well as potential solutions to solve them.

1. High Object Creation Rate

If your application’s object creation rate is very high, then to keep up with it, the garbage collection rate will also be very high. A high garbage collection rate will increase the GC pause time as well. Thus, optimizing the application to create fewer objects is THE EFFECTIVE strategy to reduce long GC pauses. This might be a time-consuming exercise, but it is 100% worth doing. In order to optimize the object creation rate in the application, you can consider using Java profilers like JProfilerYourKit, or JVisualVM. These profilers will report:

  • What are the objects that have been created?

  • What is the rate at which these objects are created?

  • What is the amount of space they are occupying in memory?

  • Who is creating them?

Always try to optimize the objects that occupy the most amount of memory. Go after the big fish in the pond.

Tidbit: How to Figure Out the Object Creation Rate
objectstats

Upload your GC log to the Universal Garbage Collection log analyzer tool GCeasy. This tool will report the object creation rate. There will be field by name ‘Avg creation rate’ in the section ‘Object Stats.’ This field will report the object creation rate. Strive to keep this value lower. See the image (which is an excerpt from the GCeasy-generated report) showing the ‘Avg creation rate’ to be 8.83 mb.sec.

2. Undersized Young Generation

When the young generation is undersized, objects will be prematurely promoted to the old generation. Collecting garbage from the old generation takes more time than collecting it from the young generation. Thus, increasing the young generation size has the potential to reduce long GC pauses. The young generation's size can be increased by setting one of the two JVM arguments

-Xmn: specifies the size of the young generation.

-XX:NewRatio: Specifies the size of the young generation relative to the old generation. For example, setting -XX:NewRatio=2 means that the ratio between the old and young generation is 1:2. The young generation will be half the size of the overall heap. So, if the heap size is 2 GB, then the young generation size would be 1 GB.

3. Choice of GC Algorithm

Your GC algorithm has a major influence on the GC pause time. If you are a GC expert or intend to become one (or someone on your team is a GC expert), you can tune GC settings to obtain optimal GC pause time. If you don’t have a lot of GC expertise, then I would recommend using the G1 GC algorithm because of its auto-tuning capability. In G1 GC, you can set the GC pause time goal using the system property ‘-XX:MaxGCPauseMillis.’ Example:


As per the above example, the maximum GC pause time is set to 200 milliseconds. This is a soft goal, which JVM will try it’s best to meet it. 

4. Process Swapping

Sometimes due to a lack of memory (RAM), the operating system could be swapping your application from memory. Swapping is very expensive, as it requires disk accesses, which is much slower compared to physical memory access. In my humble opinion, no serious application in a production environment should be swapping. When the process swaps, GC will take a long time to complete.

Below is the script obtained from StackOverflow (thanks to the author) that, when executed, will show all the processes that are being swapped. Please make sure your process is not getting swapped.


If you find your processes are swapping, then do one of the following:

  • Allocate more RAM to the serve.

  • Reduce the number of processes that running on the server so that it can free up the memory (RAM).

  • Reduce the heap size of your application (which I wouldn’t recommend, as it can cause other side effects. Still, it could potentially solve your problem).

5. Tuning the Number of GC Threads

For every GC event reported in the GC log, user, sys, and real times are printed. Example:


To know the difference between each of these times, please read this article. (I highly encourage you to read the article before continuing this section). If, in the GC events, you consistently notice that ‘real’ time isn’t significantly less than the ‘user’ time, then it might be indicating that there aren’t enough GC threads. Consider increasing the GC thread count. Suppose ‘user’ time is 25 seconds and you have configured the GC thread count to be 5, then the real time should be close to 5 seconds (because 25 seconds/5 threads = 5 seconds).

WARNING: Adding too many GC threads will consume a lot of CPU and take away resources from your application. Thus you need to conduct thorough testing before increasing the GC thread count.

6. Background IO Traffic

If there is heavy file system I/O activity (i.e. lot of reads and writes are happening), it can also cause long GC pauses. This heavy file system I/O activity may not be caused by your application. Maybe it is caused by another process that is running on the same server. Still it can cause your application to suffer from long GC pauses. Here is a brilliant article from LinkedIn Engineers that walks through this problem in detail.

When there is heavy I/O activity, you will notice the ‘real’ time to be significantly higher than ‘user’ time. Example:


When this happens, here are some potential solutions to solve it:

  • If high I/O activity is caused by your application, then optimize it.

  • Eliminate the processes that are causing high I/O activity on the server.

  • Move your application to a different server where there is less I/O activity.

Tidbit: How to Monitor I/O Activity

You can monitor I/O activity, using the sar (System Activity Report), in Unix. Example:


The above command reports the reads/sec and writes/sec made to the device every 1 second. For more details on the ‘sar’ command, refer to this tutorial.

7. System.gc() Calls

When System.gc() or Runtime.getRuntime().gc() method calls are invoked, it will cause stop-the-world full GCs. During stop-the-world full GCs, the entire JVM is frozen (i.e. No user activity will be performed during this period). System.gc() calls are made from one of the following sources:

  1. Your own developers might be explicitly calling the System.gc() method.
  2. It could be third-party libraries, frameworks, or sometimes even application servers that you use. Any of those could be invoking the System.gc() method.
  3. It could be triggered from external tools (like VisualVM) through the use of JMX.
  4. If your application is using RMI, then RMI invokes System.gc() on a periodic interval. This interval can be configured using the following system properties:

-Dsun.rmi.dgc.server.gcInterval=n  

-Dsun.rmi.dgc.client.gcInterval=n  

Evaluate whether it’s absolutely necessary to explicitly invoke System.gc(). If there is no need for it, then please remove it. On the other hand, you can forcefully disable the System.gc() calls by passing the JVM argument: -XX:+DisableExplicitGC. For complete details on System.gc() problems and solution refer to this article.

Tidbit: How to Know Whether System.gc() Calls Are Explicitly Called?
gccauses

Upload your GC log to the Universal Garbage Collection log analyzer tool GCeasy. This tool has a section called ‘GC Causes.’ If GC activity is triggered because of ‘System.gc()’ calls, then it will be reported in this section. See the image (which is an excerpt from the GCeasy-generated report), showing that System.gc() was made four times during the lifetime of this application.

CAUTION: All of the above-mentioned strategies should be rolled to production only after thorough testing and analysis. All strategies may not apply to your application. Improper usage of these strategies can result in negative results.

Jan 12, 2022

Java option to generate log for class loader.

 Use option -verbose:class

to generate logs for a list of classes loaded from which jar file.

Dec 16, 2021

OCI: Extending the Root Partition on a Linux-Based Image

 Command to expend the root partition from default 50GB to allocated disk space while creating instance.

$ sudo /usr/libexec/oci-growfs
CHANGE: disk=/dev/sda partition=3: start=17188864 old: size=80486399,end=97675263 new: size=192526302,end=209715166
Confirm? [y/n]: y
CHANGED: disk=/dev/sda partition=3: start=17188864 old: size=80486399,end=97675263 new: size=192526302,end=209715166
	meta-data=/dev/sda3              isize=256    agcount=4, agsize=2515200 blks
	=                       sectsz=4096  attr=2, projid32bit=1
	=                       crc=0        finobt=0 spinodes=0
	data     =                       bsize=4096   blocks=10060800, imaxpct=25
	=                       sunit=0      swidth=0 blks
	naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
	log      =internal               bsize=4096   blocks=4912, version=2
	=                       sectsz=4096  sunit=1 blks, lazy-count=1
	realtime =none                   extsz=4096   blocks=0, rtextents=0
	data blocks changed from 10060800 to 24065787
Source: https://docs.oracle.com/en-us/iaas/Content/Compute/References/oci-growfs.htm#ocigrowfs

Dec 8, 2021

ORA-01591: lock held by in-doubt distributed transaction

 ORA-01591: lock held by in-doubt distributed transaction


If you got ” ORA-01591: lock held by in-doubt distributed transaction ” error, it means there are some uncommitted transactions in the database.

We need to perform rollback or commit force for Uncommitted transactions to solve this problem.


ORA-01591

You can query uncommitted or pending transaction with following script. This script will generate rollback force command also, so you can execute the result of following command.

SQL> select 'rollback force '''||local_tran_id||''';' from DBA_2PC_PENDING where state='prepared';

rollback force '72.6.1262301';


You can perform rollback related transaction with following command.

SQL> rollback force '72.6.1262301';


lock held by in-doubt distributed transaction

Following script will generate commit force command also, so you can execute the result of following command.

SQL> select 'commit force '''||local_tran_id||''';' from DBA_2PC_PENDING where state='prepared';

commit force '72.6.1262301';

You can perform force commit to related transaction with following command.


SQL> commit force '72.6.1262301';


Source:- https://ittutorial.org/ora-01591-lock-held-by-in-doubt-distributed-transaction/

May 30, 2021

Command to resolve display issue for Oracle Linux

xauth add `echo "${DISPLAY}" | sed 's/.*\(:.*\)/\1/'` . `mcookie`


Source: https://bbs.archlinux.org/viewtopic.php?id=98524

Feb 11, 2021

TMF814 Corba API Tips

 1. Use an existing holder to fetch next_n elements instead of creating a new holder for better performance.

Oct 14, 2020

Update Ubuntu with latest packages

Steps to update packages

$ sudo apt update

$ sudo apt list --upgradable

$ sudo apt install <SPECIFIC_PACKAGE_NAME>

or

$ sudo apt upgrade  

 

Oct 13, 2020

Running VNC Server on OCI Linux 7

 Step 1: Install the GUI server

$ sudo yum group install "Server with GUI" -y

Step 2: Install VNC Server

$ sudo yum install tigervnc-server tigervnc-server-module -y

Step 3: Create a password for vncserver

$ vncpasswd

Step 4: Copy vncserver@.service to /etc/systemd/system/

$ sudo cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/. 

Step 5: Edit /etc/systemd/system/vncserver@.service for Linux user.

$ sudo vi /etc/systemd/system/vncserver@.service

Search for below line and replace <USER> with opc as mentioned 
ExecStart=/usr/bin/vncserver_wrapper opc %i -geometry 1366x768

Step 6: Starting VNC Server

$ sudo systemctl daemon-reload

$ sudo systemctl start vncserver@:1.service (Here :1 is the port of vncserver)

$ sudo systemctl enable vncserver@:1.service

$ sudo systemctl status vncserver@:1.service

 Step 7: Tunneling VNC server port onto localhost (use Git Bash, in case of Windows OS)

$ ssh -v -C -L 5901:localhost:5901 opc@<public_ip> -i <private_key>

Step 8: Connect to VNC session using "localhost:5901"


// We can also access the VNC session directly, by opening 5901 open in Linux firewall. 

Step 7a: Open port '5901' in the firewall configuration.

$ sudo firewall-cmd --zone=public --permanent --add-port=5901/tcp

$ sudo firewall-cmd --reload 

 


 

Basic Test Framework with Protractor-Jasmine-TypeScript-NodeJS.

Basic Test Framework with Protractor-Jasmine-TypeScript-NodeJS, provides a bootstrap platform to write UI automation test cases for Angular applications.

https://github.com/ksuresh8/HelloProtractor

For more details: https://github.com/ksuresh8/HelloProtractor/blob/main/README.md



How to enable ping for OCI Instance?

The most secure method to allow ping requests is to add an ICMP rule with the following details:

Source: 0.0.0.0/0
IP Protocol: ICMP
Type Code: 8 (Type code definitions)