rotateActiveFile rotates log file when active file is not enough space to store the entry.
()
| 480 | |
| 481 | // rotateActiveFile rotates log file when active file is not enough space to store the entry. |
| 482 | func (tx *Tx) rotateActiveFile() error { |
| 483 | var err error |
| 484 | tx.db.MaxFileID++ |
| 485 | |
| 486 | if !tx.db.opt.SyncEnable && tx.db.opt.RWMode == MMap { |
| 487 | if err := tx.db.ActiveFile.rwManager.Sync(); err != nil { |
| 488 | return err |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | if err := tx.db.ActiveFile.rwManager.Release(); err != nil { |
| 493 | return err |
| 494 | } |
| 495 | |
| 496 | // reset ActiveFile |
| 497 | path := getDataPath(tx.db.MaxFileID, tx.db.opt.Dir) |
| 498 | tx.db.ActiveFile, err = tx.db.fm.GetDataFile(path, tx.db.opt.SegmentSize) |
| 499 | if err != nil { |
| 500 | return err |
| 501 | } |
| 502 | |
| 503 | tx.db.ActiveFile.fileID = tx.db.MaxFileID |
| 504 | return nil |
| 505 | } |
| 506 | |
| 507 | func (tx *Tx) writeData(data []byte) (n int, err error) { |
| 508 | if len(data) == 0 { |
no test coverage detected