Search

kmagen2

MySql Crash – can’t Restart


Common command

service mysqld start 
service mysqld stop 
service mysqld restart

1. If you know that a given table is causing a crash on rollback, you can drop it.

2. Full guide – depend on your special situation :

https://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html

InnoDB: Progress in percents: 109:10:30 UTC - mysqld got signal 11 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
Thread pointer: 0x7f2482567ac0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7f215ceccba0 thread_stack 0x46000
2020-07-08T09:10:30.413066Z 2 [Warning] [MY-011018] [Server] Skip updating information_schema metadata in InnoDB read-only mode.
2020-07-08T09:10:30.414443Z 0 [Warning] [MY-010970] [Server] Skipped updating resource group metadata in InnoDB read only mode.
2020-07-08T09:10:30.414619Z 0 [Warning] [MY-010970] [Server] Skipped updating resource group metadata in InnoDB read only mode.
/usr/sbin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x3d) [0x1f104dd]
/usr/sbin/mysqld(handle_fatal_signal+0x333) [0xf8b933]
/lib64/libpthread.so.0(+0xf5f0) [0x7f2abfcd95f0]
/usr/sbin/mysqld(dtuple_convert_big_rec(dict_index_t*, upd_t*, dtuple_t*, unsigned long*)+0xb62) [0x2279e02]
/usr/sbin/mysqld(btr_cur_pessimistic_update(unsigned long, btr_cur_t*, unsigned long**, mem_block_info_t**, mem_block_info_t*, big_rec_t**, upd_t*, unsigned long, que_thr_t*, unsigned long, unsigned long, mtr_t*)+0x2ef) [0x21fc59f]
/usr/sbin/mysqld() [0x236f926]
/usr/sbin/mysqld() [0x2370047]
/usr/sbin/mysqld(row_undo_mod(undo_node_t*, que_thr_t*)+0xcbf) [0x237331f]
/usr/sbin/mysqld(row_undo_step(que_thr_t*)+0x60) [0x213bb40]
/usr/sbin/mysqld(que_run_threads(que_thr_t*)+0x988) [0x20cbb08]
/usr/sbin/mysqld(trx_rollback_or_clean_recovered(unsigned long)+0xbba) [0x219affa]
/usr/sbin/mysqld(trx_recovery_rollback_thread()+0x30) [0x219c020]
/usr/sbin/mysqld(std::thread::_State_impl<std::thread::_Invoker<std::tuple<Runnable, void (*)()> > >::_M_run()+0xb5) [0x2072995]
/usr/sbin/mysqld() [0x263cf3f]
/lib64/libpthread.so.0(+0x7e65) [0x7f2abfcd1e65]
/lib64/libc.so.6(clone+0x6d) [0x7f2abde5888d]

Troubleshould error Curl


 

1. Debug

curl -I https://storage.googleapis.com -vv

2. Error:

  • * NSS error -5938 (PR_END_OF_FILE_ERROR)
  • curl: (35) Encountered end of file

3. Try fix:

a. Check and upgrade version cURL

yum update curl

b. Vefiry SSL – Cert

openssl verify -verbose -x509_strict

c. Check Firewal / IPtable …

 

Random array in JavaScript


let shuffled = listPost.map((a) => [Math.random(),a]).sort((a,b) => a[0]-b[0]).map((a) => a[1]);

 

Next JS


  1. React Component is the “default export”
  2. *** Use Webpack’s hot module replacement -> Support default
  3. Navigate between Pages
    • Not use
    • Use  from ‘next/link’ -> use client-side navigation -> not send request to server 
  4. ‘/pages’, ‘/static’ –> special  folder -> not change name
  5. Layout : 3 ways
    1. Render child component
    2. Layout as a higher component
    3. Page content as prop
  6. Component: use as Header / Layout

… for styling / page layout, … 

…can import components from NPM modules and use them.

 

MySQL 8.0 Supported Storage Engines


  • InnoDB: The default storage engine in MySQL 8.0. InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data. InnoDB row-level locking (without escalation to coarser granularity locks) and Oracle-style consistent nonlocking reads increase multi-user concurrency and performance. InnoDB stores user data in clustered indexes to reduce I/O for common queries based on primary keys. To maintain data integrity, InnoDB also supports FOREIGN KEY referential-integrity constraints. For more information about InnoDB, see Chapter 15, The InnoDB Storage Engine.
  • MyISAM: These tables have a small footprint. Table-level locking limits the performance in read/write workloads, so it is often used in read-only or read-mostly workloads in Web and data warehousing configurations.
  • Memory: Stores all data in RAM, for fast access in environments that require quick lookups of non-critical data. This engine was formerly known as the HEAP engine. Its use cases are decreasing; InnoDB with its buffer pool memory area provides a general-purpose and durable way to keep most or all data in memory, and NDBCLUSTER provides fast key-value lookups for huge distributed data sets.
  • CSV: Its tables are really text files with comma-separated values. CSV tables let you import or dump data in CSV format, to exchange data with scripts and applications that read and write that same format. Because CSV tables are not indexed, you typically keep the data in InnoDB tables during normal operation, and only use CSV tables during the import or export stage.

Table 16.1 Storage Engines Feature Summary

Feature MyISAM Memory InnoDB Archive NDB
B-tree indexes Yes Yes Yes No No
Backup/point-in-time recovery (note 1) Yes Yes Yes Yes Yes
Cluster database support No No No No Yes
Clustered indexes No No Yes No No
Compressed data Yes (note 2) No Yes Yes No
Data caches No N/A Yes No Yes
Encrypted data Yes (note 3) Yes (note 3) Yes (note 4) Yes (note 3) Yes (note 3)
Foreign key support No No Yes No Yes (note 5)
Full-text search indexes Yes No Yes (note 6) No No
Geospatial data type support Yes No Yes Yes Yes
Geospatial indexing support Yes No Yes (note 7) No No
Hash indexes No Yes No (note 8) No Yes
Index caches Yes N/A Yes No Yes
Locking granularity Table Table Row Row Row
MVCC No No Yes No No
Replication support (note 1) Yes Limited (note 9) Yes Yes Yes
Storage limits 256TB RAM 64TB None 384EB
T-tree indexes No No No No Yes
Transactions No No Yes No Yes
Update statistics for data dictionary Yes Yes Yes Yes Yes

“BEGIN OPENSSH PRIVATE KEY”….“BEGIN RSA PRIVATE KEY”


Tips – Errors

  1. “BEGIN OPENSSH PRIVATE KEY”….

* Env: Mac Mojave  10.14.1/ O

  • Generate new ssh key with old format “BEGIN RSA PRIVATE KEY”
      • ssh-keygen -m PEM
  • Convert by ssh-keygen
    • ssh-keygen -e -m PEM -f id_rsa > ..output ( or -G … print_out )
      • only convert public key
  • Covert Private Key = puttygen
      • puttygen <fileInput> -O <format> -o <output>
      • puttygen id_rsa -O private-openssh -o id_rsa_new

https://www.openssh.com/txt/release-7.8

https://www.openssh.com/releasenotes.html

https://unix.stackexchange.com/questions/84060/convert-openssh-private-key-into-ssh2-private-key

https://linux.die.net/man/1/puttygen

Upstream sent too big header while reading response header from upstream


folder_structure_rewrite_template_email
Folder Structure Rewrite template email order, invoice, shipment

Add new folder into theme folder is using

1.Order Email

<?= $block->escapeHtml($_item->getProduct()->getData('short_description')) ?>

2.Invoice Email + Shipment Email

<?php
 $objManager = \Magento\Framework\App\ObjectManager::getInstance();
 $itemId = $_item->getProductId();
 $productObject = $objManager->create('Magento\Catalog\Model\Product')->load($itemId);
 $short_description = $productObject->getShortDescription();
 ?>
 <?= $block->escapeHtml($short_description) 
?>

Magento: The Right Way


 

Magento: The Right Way

Introduction

This isn’t a tutorial. This is a (debatable) list of things I think you should be doing as a Magento Developer. This is a living document and would love some recommendations on content as well as another set of eyes over the content.

As you might have guessed, this site borrows shamelessly from the brilliant PHP: The Right Way.

Themes

The theme that accompanies your store will invariably be the biggest component of your build and so it’s important to build it correctly.

Blocks

  • Develop your blocks in such a way that a future developer can make any modifications required by calling <action method="name" /> in the layout.xml.
  • Don’t override the getTemplate() method, or if you do, $this->hasData('template')first.
  • Don’t use $this->assign($name, $value) in blocks. Nobody likes surprises.

Templates

  • Ensure your strings are wrapped with $this->__('') for translations.
  • Add /** @var $this Mage_Core_Block_Template */ (replacing the correct class name) at the top of your template file – your IDE will love you.
  • Keep as much of your logic in your block as possible. This makes the logic reusable and allows the delegation of templating tasks to less experienced members of staff.

Layouts

  • Use <update handle="" /> to refactor repeated block declarations.
  • Move blocks from one reference to another using <action method="unsetChild"></action> and <action method="insert"></action>.
  • Create a local.xml in your theme as a place to store all of your theme modifications. Don’t create catalog.xmlcustomer.xmlpage.xml, etc, files.

  • When creating an extension that requires layout changes:
    • Do not ship with your own copy of a local.xml file
    • Create your own layout file with a unique name following your module namespace, for example, $companyname/$modulename.xml
    • Place your layout file (and its accompanying template files) in the base/defaulttheme so that it may be accessed by all installed themes.
  • A reusable theme is, for all intents and purposes, an extension to Magento and should also not ship with a customised local.xml (discussion).

Extensions

All modifications to the core functionality of Magento should be done by way of Magento extensions.

A strong incentive for migrating to Magento is the number of extensions on Magento Connect. Unlike Apple’s App Store, there is no code review nor quality control procedure to listings. These extensions should reside within the community code pool.

When building a Magento store, it is likely that you will have to add custom code in order to:

  • Overwrite core functionality
  • Overwrite community extension functionality
  • Add independent/additional functionality

These changes should be made in a modular fashion (loosely coupled and high cohesion) within the local code pool.

Do not edit the core code pool.

Third Party Extensions

  • Perform a code review of any extension you install on a client site.
  • Don’t edit any 3rd party extension directly, because your changes may be lost when the extension is updated. Instead, create your own local module that depends on the one you want to edit and that either rewrites its models/blocks or uses events to achieve the desired effect.
  • Check if the extension you are about to install doesn’t rewrite any models or blocks already rewritten by other extensions on your Magento instance. If it does, you are facing a rewrite conflict and you need to make your own local module that depends on both modules (so it’s loaded after them) and rewrites the same models/blocks in a way that won’t prevent any of conflicting modules from working correctly.
  • Build a list of trusted (and untrusted) extension providers.

Observers

The best way to add code to Magento is to make use of the events system. This allows custom code to be fired upon receipt of an event without having to rewrite models or blocks.

Developing with observers means that the code is more independent and less likely to conflict with other extensions.

  • Take a look at this events cheat sheet for an idea of where events are fired.
  • When developing your own extensions try and fire events at points where developers may consider extending your code in the future with Mage::dispatchEvent.
  • Always try to listen to specific events instead of generic events that are dispatched multiple times during the application life cycle. This will make sure that the code only runs when it’s necessary.

Admin Area

  • Use an ACL entry to allow administators to restrict, based on user roles, access to your interface.
  • Extend from Mage_Adminhtml_Controller_Action when creating your admin controllers to inherit session configuration changes and CSRF mitigation, amongst other things.
  • Use the standard /admin prefix for your admin routes instead of inventing your own.

Debugging

There are plenty of methods to debug Magento issues. Most problems can be resolved with a fundamental understanding of how components fit together, along with a good idea of where to start looking. For everything else there’s xdebug.

The Varien_Object

  • Don’t var_dump(), you’ll probably get a WSOD.

You can inspect the contents of a Varien_Object with the ->debug() method.

Logging

  • Write to log files in var/log/ by using Mage::log($message, $severity, $filename, $force).
  • Use the severity levels as defined in Zend_Log.
  • Write to your own file, try to stick to the naming convention $company_$extension_$specific.log, e.g. meanbee_shippingrules_requests.log.
  • Add a “Debug Mode” toggle to your extension that forces logging, even if globally disabled.
  • eCommerce applications require traceability and the rapid tracking down of issues, so log anything that might make your life easier in the future.
  • There’s nothing worse than an empty log file, although a log file full of useless crap comes a close second.

Database Queries

  • There are a number of methods to retrieve the SQL behind most collection queries for debugging:
    • $collection->getSelect()->assemble()
    • $collection->printLogQuery(true) will echo, $collection->printLogQuery(false, true) will log to system.log
    • Setting the value of Varien_Db_Adapter_Pdo_Mysql::$_debug to true will log all queries to Varien_Db_Adapter_Pdo_Mysql::$_debugFile.

Performance

Shops should be fast. Page loading times have a known direct impact on conversion rates.

Frontend

Most of the traditional frontend developer techniques to improve your website’s speed apply to Magento – it’s a web application after all.

  • Enable merging CSS and JS files in Magento. You can use Fooman Speedster Advanced for on-the-fly minification and intelligent combined file grouping.

Backend

There are few basic methods to speed up Magento installation, a number of which are described in an official Magento whitepaper on the topic.

  • For your database server use Percona instead of MySQL.
  • For better application performance use PHP version >= 5.4. Here some benchmarks and the latest 5.4 support patch.
  • Install a bytecode cache for PHP such as APC.
  • Remember to disable Xdebug on production servers.
  • Use nginx + php-fpm instead of apache.
  • Ensure Magento cache is enabled in production environments.
  • Use Varnish for full page caching. Use Turpentine for (almost) drop-in support.
  • To reduce SQL queries avoid loading models inside loops, try to get the collection from the database in a single request and iterate over the result set instead.

Development Tools

There are a number of tools that have emerged to make your life as a Magento Developer easier.

  • modman – Magento Module Manager
  • Ecomdev_PHPUnit – PHPUnit Integration
  • BehatMage – Behat for Magento
  • MageSpec – PHPSpec for Magento
  • magerun – Magento Command Line Tools
  • magetool – Other magento command line tools.
  • dac (Duplicate and Commit) – Easier base/default template duplication for Git
  • PHPCS – PHP CodeSniffer. Keep your coding style consistent. Magento specific styles are from Magento ECG and made.com
  • PhpStorm with the Magicento plugin – PHPStorm is a full-fledged PHP IDE, and the Magicento plugin adds a lot of Magento-specific features.
  • Wiz is a CLI tool for configuring and listing settings from the command line, among other things.

Testing

Testing Magento can be difficult, but there are tools out there to make it easier.

Upstream sent too big header while reading response header from upstream


Nginx 502 Bad Gateway error

[error] 5470#5470: *324 upstream sent too big header while reading response header from upstream, client: 10.254.251.177, server: abc.test.com, request: “POST /in_en/customcheckout/ HTTP/1.1”, upst ream: “fastcgi://127.0.0.1:9000”, host: “abc.com”, referrer: “https://abc.com/in_en/customcheckout/&#8221;

Configuration file /etc/nginx/nginx.conf :

http {
    ...
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    ...
}

client_max_body_size 100m;


Prefer:
https://github.com/magenx/Magento-nginx-config/blob/master/magento1/nginx.conf

Blog at WordPress.com.

Up ↑