segunda-feira, 7 de outubro de 2019

HANA startup tuning – part 1

One of the biggest challenges with SAP HANA databases are the duration of the startups. Here we have to separate the available time and the reload time.
In my career as consultant I’ve seen a lot of HANA databases with pretty long startup times with more than 1 hour. This is also the reason why SAP introduced the fast restart option with SPS4. But which possibilities are there to speed up which phase with which release? Because a lot of DBs are still not on SPS4 and can not profit from new features. How you can identify the bottleneck?
To understand which phase is your pain point, we have to understand how the DB starts and which phase can be optimized.
In any case we assume that the DB was stopped normally which includes a global save point at the end of the shutdown phase.
1. Open the data files
2. load converter tables from the last savepoint (mapping of logical pages to physical pages in the data file)
3. load the list of open transactions from the last savepoint
4. load RS tables
5. replay redo log entries
6. Roll back uncommited transactions
7. Perform global savepoint

Phases in detail

For our little deep dive this information are not enough.
Details for every phase: 2222217 – How-To: Troubleshooting SAP HANA Startup Times
To give you an example I setup a test environment with a 8TB HANA DB with HANA 2.0 SPS3 Rev. 36.
Hint: To find the begin of a start phase search for “==== Starting hdbindexserver“.
#as sidadm
cdtrace
grep "==== Starting hdbindex" *
view index*.trc

PhaseCategoryDescriptionoptimize tasksStartEndDuration
PersistentSpaceImpl.cppPersistenceManagerload ConvertersI/O performance09:24:1009:24:5300:00:43
FileIDMapping.cppContainerDirectoryLoad Container / FileID MappingI/O performance / number of containers09:25:2709:31:2000:05:53
VirtualFileStatsProxy.cppPMRestartLOB Owner statistics from Virtual Fileoptimize LOB size or type (packed LOBs)09:31:2510:02:3000:31:05
AbsolutePageAccessImplRowStorePageAccessCollecting RowStore Pagesreduce RS size (reorg)10:02:3610:03:5000:01:14
CheckpointMgr.ccService_StartupRowStore Loadreduce RS size (reorg)10:02:3610:04:4700:02:11
RecoveryHandlerImp.cppLoggerLog recoveryI/O performance / number of open transactions10:04:5510:04:5700:00:02
PersistenceManagerImpl.cppPersistenceManagerPersistenceManager Status
(only seen over 6TB)
reduce DB size / optimize I/O performance10:04:5710:09:1700:04:20
IntegrityCheckerTimer.hService_StartupConsistency Check RowStorereduce RS size (reorg) or disable indexserver.ini
-> [row_engine] -> consistency_check_at_startup -> none
10:09:1810:14:1400:04:56
TRexApiSystem.cppTableReloadColumnStore Table Reloadtables_preloaded_in_parallel > 510:14:3310:32:0100:17:28

PersistentSpaceImpl.cpp / PersistenceManager

FileIDMapping.cpp / ContainerDirectory

=> in this phase the container directory is read from disk and memory structures for statistics are set up.

VirtualFileStatsProxy.cpp / PMRestart

=> this phase is single threaded! Try to reduce the LOB files. Here is room for some improvement (parallelism) @SAP  😉
The reason for this long phase are 1,6TB of HybridLOBs.
Here are the Flame Graph of this phase:

AbsolutePageAccessImpl / RowStorePageAccess / CheckpointMgr.cc / Service_Startup

=> loading RS pages

RecoveryHandlerImp.cpp / Logger

PersistenceManagerImpl.cpp / PersistenceManager

=> here the global savepoint is written

IntegrityCheckerTimer.h / Service_Startup

=> RowStore consistency check which can be affected with parameter consistency_check_at_startup:
“Configure row store consistency check during SAP HANA startup: This parameter is used to configure a row store consistency check via CHECK_TABLE_CONSISTENCY during SAP HANA startup. It’s a list parameter and the allowed values are ‘table’, ‘page’ and ‘index’, which perform consistency checks on ‘table’, ‘page’ and ‘index’ respectively. This consistency check can be disabled by setting the parameter value to ‘none’.”

TRexApiSystem.cpp / TableReload

=> reload with 5 threads. With enough CPUs you can improve this phase with more parallel threads
=> lazy reload finished
Background info RS
Since HANA 1.0 SPS09 there is a hidden parameter keep_shared_memory_over_restart which keeps the Row Store in memory also after a DB restart. Therefor you will see a process called hdbrsutil which keeps the tables attached to the shared memory. (2159435 – How-To: Keeping SAP HANA Row Store in Memory when restarting)
Background info CS
Since HANA 2.0 SPS4 there were some changes in the startup of RS and CS tables. The load of LOBs is optimized and there is a new feature which is called fast restart option. Since Rev. 35 there is also the possibility to use pmem if you have the correct hardware (cascade lake).

SPS3 vs SPS4

  • Compared you can see exact same DBs
  • No load (=no application server online) on both systems while testing
  • The startup was tested 3 times per release
  • The best and worst were not used
  • no parameter improvements
  • SPS4 without fast restart options
  • result: round about 10min faster till available
  • improvements in virtual file statistics with SPS4
  • Reload of CS slower with SPS4
The second part will describe the fast restart option of SPS4. How it works and how easy you can set it up.

Um comentário: