Saturday, 29 June 2024

What are triggers in SAP HANA environments ?

 Triggers in SAP HANA environments are database objects that automatically execute a specified set of SQL statements or logic in response to certain events on a particular table or view. They are used to enforce business rules, maintain data integrity, and automate system processes. Here’s a detailed overview of triggers in SAP HANA:

Example:

CREATE TRIGGER
  "_SYS_STATISTICS"."STATISTICS_SWITCH_PROFILE"
AFTER UPDATE ON
  "_SYS_STATISTICS"."STATISTICS_PROPERTIES"
REFERENCING OLD ROW MYOLDROW, NEW ROW MYNEWROW FOR EACH ROW
begin  
  if :mynewrow.key = 'internal.sizing.profile' then
    if :mynewrow.value != :myoldrow.value then
      call _SYS_STATISTICS.shared_copy_profiles (:myoldrow.value, :mynewrow.value);
    end if;
  end if;
end

 

Types of Triggers in SAP HANA

  1. Row-Level Triggers: These triggers execute once for each row affected by the triggering event. They are useful for enforcing row-specific constraints or logging changes.
  2. Statement-Level Triggers: These triggers execute once for the entire SQL statement, regardless of how many rows are affected. They are used for actions that apply to the whole statement, such as auditing.

Trigger Events

Triggers can be defined to execute in response to the following events:

  1. INSERT: Activates when a new row is inserted into the table.
  2. UPDATE: Activates when an existing row is updated.
  3. DELETE: Activates when a row is deleted from the table.

Timing of Triggers

Triggers can be specified to execute at different times relative to the triggering event:

  1. BEFORE: Executes before the triggering event. Used for validation or modification of data before it is committed.
  2. AFTER: Executes after the triggering event. Used for logging, enforcing business rules, or cascading changes to other tables.
  3. INSTEAD OF: Executes in place of the triggering event. Commonly used for views to provide custom behavior for insert, update, or delete operations.


This trigger is executed in context of the SAP HANA statistics server (SAP Note 2147247) after updates on table STATISTICS_PROPERTIES in order to make sure that under certain key / value conditions the procedure SHARED_COPY_PROFILES is called in order to perform follow-up actions.

2800020 - FAQ: SAP HANA Triggers

Thanks !

 

How can I interpret the thread state? or What are different state of thread in SAP HANA database ?

 In SAP HANA, threads can be in various states, each indicating a different stage of their lifecycle or activity type. Understanding these thread states is crucial for diagnosing performance issues and optimizing system performance. 



Here are the different thread states in SAP HANA:

 

 

 

Thread state

Area

Details

Barrier Wait

Lock 

Barrier wait

ConditionalVariable Wait

Lock 

Mainly record and table lock waits, but also some internal locks

ConditionalVar Wait

ExclusiveLock Enter

Lock

Exclusive read / write lock waits

Futex Wait

Lock

Futex lock wait

Inactive

Idle

Idle thread

IntentLock Enter

Lock

Intentional read / write lock waits

IO Wait

I/O

Disk I/O wait (e.g. during column load or hybrid LOB access)

Job Exec Waiting

Idle

Waiting for a JobWorker thread executing the actual work

Joining

Idle

Joining of execution context of another thread, i.e. waiting for the termination of the other thread

Mutex Wait

Lock

Mutex lock waits

Network Connect

Network

Network I/O between SAP HANA nodes or services, timeouts can be configured with client properties like connectTimeout and nodeConnectTimeout (SAP Note 2186744)

Network Poll

Network

Network I/O between SAP HANA nodes or services

Network Read

Network

Network I/O read between SAP HANA nodes or services

Network Write

Network

Network I/O write between SAP HANA nodes or services

Resource Load Wait

I/O

Disk I/O wait (e.g. during undo file load, DataAccess::UndoFileAnchor::allocateFile)

Running

SQL

Request execution, typically CPU consumption

Semaphore Wait

Lock

Semaphore lock waits

SharedLock Enter

Lock

Shared read / write lock waits

Sleeping

Lock

Waiting for a lock

Speculative Lock Retry backoff

Lock

Transactional memory lock (back-off waiting on transaction retry)

Speculative Lock Wait for fallback

Lock

Transactional memory lock state (waiting on fallback lock)

TimestampLatch Wait

Lock

Waiting for a timestamp latch

3rd party Thread

Unknown

State of Native threads created outside of the standard SAP HANA context can't be determined and so they are displayed as '3rd party Thread' (SAP HANA >= 2.00.059.06, >= 2.00.065).

 

THREAD_DETAIL may contain related call stack details


                                                                                                                       

Thanks !

Wednesday, 26 June 2024

Alert of type [Subaccount Certificate] has been triggered by Cloud Connector

We may received the below error while requesting a Subaccount Certificate in Cloud Connector.

Error: 

An error occurred when trying to connect. See 'Log And Trace Files' and in particular ljs_trace.log for details. Associated entries were logged on or around 2024-06-26 14:35:18,160 +0000."


Resolution: 

The error message indicates that there was an issue connecting to the system, and it suggests checking the 'Log And Trace Files' for more details, specifically the ljs_trace.log file around the timestamp provided. Here are the steps to diagnose and resolve this issue:

Steps to Diagnose and Resolve the Connection Error

1. Check the Log Files

  • Locate the Log Files: Find the ljs_trace.log file. This is typically located in the log directory of your SAP HANA installation.
  • Review the Logs: Open the ljs_trace.log file and look for entries around 2024-06-26 14:35:18,160 +0000. This should give you more specific information about the error
2: User Name and Password / Authorization 

          Please ensure the username and password we are providing have sufficient rights. most of the time S-User ID password will work. 

3. Contact SAP Support

  • Support Ticket: If the issue persists and you are unable to resolve it with the above steps, consider opening a support ticket with SAP for further assistance. Provide them with the log details and any other relevant information.

HANA Database- Column store table delta Merge failed with error "column store error: [2484] not enough memory for table optimization"

The error "column store error: [2484] not enough memory for table optimization" in SAP HANA indicates that the system does not have enough memory available to perform a delta merge operation. Here are some steps you can take to address this issue:

1. Check Memory Allocation and Usage

  • Monitor Memory Usage: Use the SAP HANA Studio or SAP HANA Cockpit to monitor memory usage. Check the Allocated Memory, Used Memory, and Free Memory.
  • Increase Memory Allocation: If possible, increase the memory allocation for the HANA system. This may involve adding more physical RAM to the server or adjusting HANA configuration settings to allocate more memory to the database.

2. Optimize Table Design and Indexes

  • Table Partitioning: If the table is very large, consider partitioning it. Partitioning can help manage memory usage more efficiently.
  • Column Compression: Ensure that columns are using appropriate compression methods to reduce memory footprint.

3. System Configuration

  • Parameter Tuning: Review and adjust the HANA database parameters related to memory management. Parameters such as global_allocation_limit and delta_merge_threshold can be tuned to optimize memory usage.
  • Unload Unused Tables: Unload tables that are not currently in use to free up memory.

4. Manage Delta Merges

  • Manual Delta Merge: If automatic delta merges are causing memory issues, consider performing manual delta merges during off-peak hours when system usage is low.
  • Delta Merge Configuration: Adjust the frequency and threshold of delta merges to better fit your system's memory capacity.

5. System Housekeeping

  • Cleanup Unused Objects: Remove or archive unused tables, indexes, and data that may be consuming memory unnecessarily.
  • Reclaim Memory: Use HANA's garbage collection and memory reclaim processes to free up memory from deleted or outdated objects.

6. Hardware Upgrade

  • Increase Physical Memory: If the system consistently runs into memory issues, it may be necessary to upgrade the server's physical memory.

7. SAP Support

  • Open a Support Ticket: If the issue persists and cannot be resolved with the above steps, consider opening a support ticket with SAP for further assistance.

Monitoring Tools:

  • SAP HANA Studio: Use the performance tab and memory overview to track memory usage.
  • SAP HANA Cockpit: Provides a detailed view of memory consumption and other performance metrics.
By following these steps, you should be able to diagnose and resolve the memory issue affecting the delta merge operation in your SAP HANA database.