Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
There is a possible NPE when a wal is closed during waledit append because of not setting write entry to the wal key. Here is the code we are not setting write entry to wal key when when wal is closed.
if (this.closed) { throw new IOException( "Cannot append; log is closed, regionName = " + hri.getRegionNameAsString()); } MutableLong txidHolder = new MutableLong(); MultiVersionConcurrencyControl.WriteEntry we = key.getMvcc().begin(() -> { txidHolder.setValue(ringBuffer.next()); }); long txid = txidHolder.longValue(); try (TraceScope scope = TraceUtil.createTrace(implClassName + ".append")) { FSWALEntry entry = new FSWALEntry(txid, key, edits, hri, inMemstore); entry.stampRegionSequenceId(we); ringBuffer.get(txid).load(entry); } finally { ringBuffer.publish(txid); } return txid;
But on failure complete on mvcc will be called with nulll write entry cause NPE.
WriteEntry writeEntry = null; try { long txid = this.wal.append(this.getRegionInfo(), walKey, walEdit, true); // Call sync on our edit. if (txid != 0) { sync(txid, durability); } writeEntry = walKey.getWriteEntry(); } catch (IOException ioe) { if (walKey != null) { mvcc.complete(walKey.getWriteEntry()); } throw ioe; }
We are able to reproduce with mocking in one of the phoenix test cases to test wal replay.