Terminal Terminal | Web Web
Home  //  Play

Manticore FREEZE and UNFREEZE

Difficulty: Beginner
Estimated Time: 10 minutes

Manticore Search - FREEZE and UNFREEZE

In this course, you will learn how to use FREEZE, UNFREEZE, and SHOW LOCKS to safely prepare RT tables for external backups.

Manticore FREEZE and UNFREEZE

Step 1 of 2

FREEZE and SHOW LOCKS

FREEZE prepares an RT table for safe external backup by preventing disk file modifications.

Let's connect to Manticore first:

mysql -P9306 -h0

Create two demo tables:

DROP TABLE IF EXISTS products;

CREATE TABLE products(title text, price float);

INSERT INTO products(id, title, price) VALUES (1, 'Red Bag', 19.85), (2, 'Blue Wallet', 45.00);

DROP TABLE IF EXISTS orders;

CREATE TABLE orders(id bigint, product_id int, customer text, amount float);

INSERT INTO orders(id, product_id, customer, amount) VALUES (1, 1, 'Alice Johnson', 19.85), (2, 2, 'Bob Smith', 90.00);

Now freeze the products table:

FREEZE products;

Use SHOW LOCKS to verify lock state:

SHOW LOCKS;

You see products with a freeze count of 1.

Try inserting into the frozen table:

INSERT INTO products(id, title, price) VALUES (10, 'Frozen Insert Test', 77.00);

SELECT * FROM products;

The insert succeeds. During FREEZE, new inserts can still go to the RAM chunk.

More behavior while a table is frozen:

  • UPDATE waits until UNFREEZE.
  • DELETE is allowed only when it does not require changing an existing disk chunk; otherwise it waits.
  • INSERT is allowed, but if RAM reaches rt_mem_limit, new inserts wait until UNFREEZE.
  • FLUSH RAMCHUNK may return success, but no real RAM-chunk save happens while frozen.
  • DROP`/`TRUNCATE are still allowed (they are explicit destructive operations).

You can also inspect the freeze counter directly:

SHOW TABLE products STATUS LIKE 'locked';

Freeze orders too:

FREEZE orders;

SHOW LOCKS;

Now both tables are listed.

If you freeze the same table multiple times, its freeze counter increases;

Try it on products:

FREEZE products;

SHOW TABLE products STATUS LIKE 'locked';

UNFREEZE and Resume Writes

Each UNFREEZE call decrements the lock counter for a table. When the counter reaches zero, normal disk operations resume.

Unfreeze products:

UNFREEZE products;

SHOW LOCKS;

Since we froze it twice, another UNFREEZE is needed

Only orders should remain locked now.

And unfreeze orders as well:

UNFREEZE orders;

SHOW LOCKS;

The result should now be empty.

Let's verify writes still work:

INSERT INTO products(id, title, price) VALUES (3, 'White Sneakers', 55.00);

SELECT * FROM products;